当前位置: 首页>>代码示例>>C++>>正文


C++ ACE_Token_Proxy类代码示例

本文整理汇总了C++中ACE_Token_Proxy的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Token_Proxy类的具体用法?C++ ACE_Token_Proxy怎么用?C++ ACE_Token_Proxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ACE_Token_Proxy类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ACE_TRACE

ACE_Token_Proxy *
ACE_Token_Handler::get_proxy (void)
{
  ACE_TRACE ("ACE_Token_Handler::get_proxy");

  // See if the proxy already exists in the collection.
  ACE_Token_Proxy *proxy = collection_.is_member (token_request_.token_name ());

  // If not, create one.
  if (proxy == 0)
    {
      proxy = this->create_proxy ();

      // Put the new_proxy in this client_id's collection.
      if (collection_.insert (*proxy) == -1)
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("insert failed\n")), 0);

      // Delete our copy (one was created in the collection).
      delete proxy;
      proxy = collection_.is_member (token_request_.token_name ());

      if (proxy == 0)
        ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("is_member failed\n")), 0);

      // Set the client_id (it was set to 1 since we're
      // single-threaded.
      proxy->client_id (token_request_.client_id ());
    }

  return proxy;
}
开发者ID:CCJY,项目名称:ACE,代码行数:31,代码来源:Token_Handler.cpp

示例2: tid

ACE_Token_Proxy *
STDIN_Token::get_proxy (const char *_tid, const char *token, char type)
{
  ACE_Token_Collection *proxy_collection;

  TID tid (_tid);

  if (collections_.find (tid, proxy_collection) == -1)
    // We did not find a proxy_collection.
    {
      // Make one.
      proxy_collection = new ACE_Token_Collection (debug_, "no name collection");

      // Put it in the collections.
      if (collections_.bind (tid, proxy_collection) == -1)
        {
          delete proxy_collection;
          return 0;
        }
    }

  // Either way, we have a proxy_collection now.

  // See if the proxy already exists in the collection.
  ACE_Token_Proxy *proxy = proxy_collection->is_member (token);

  // If not, create one.
  if (proxy == 0)
    {
      proxy = this->create_proxy (token, type);

      // Put the new_proxy in this tid's collection.
      if (proxy_collection->insert (*proxy) == -1)
        ACE_ERROR_RETURN ((LM_ERROR, "insert failed\n"), 0);

      // Delete our copy (one was created in the collection).
      delete proxy;
      proxy = proxy_collection->is_member (token);

      if (proxy == 0)
        ACE_ERROR_RETURN ((LM_ERROR, "is_member failed\n"), 0);

      // Set the client_id (it was set to 1 since we're
      // single-threaded.
      proxy->client_id (_tid);
    }

  return proxy;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:49,代码来源:manual.cpp

示例3: ACE_TRACE

int
ACE_Token_Collection::release (const ACE_TCHAR *token_name,
                               ACE_Synch_Options &options)
{
  ACE_TRACE ("ACE_Token_Collection::release");
  TOKEN_NAME name (token_name);
  ACE_Token_Proxy *temp;
  // get the token from the collection
  int result = collection_.find (name, temp);
  // did we find it?
  if (result != 0)
    return result;
  // perform the operation
  return temp->release (options);
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:15,代码来源:Token_Collection.cpp

示例4: token_name

int
ACE_Token_Collection::is_member (const ACE_Token_Proxy &token)
{
  ACE_TRACE ("ACE_Token_Collection::is_member");
  TOKEN_NAME token_name (token.name ());
  return collection_.find (token_name) == 0;
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:7,代码来源:Token_Collection.cpp

示例5: void

int
ACE_Token_Collection::tryacquire (const ACE_TCHAR *token_name,
                                  void (*sleep_hook)(void *))
{
  ACE_TRACE ("ACE_Token_Collection::tryacquire");
  TOKEN_NAME name (token_name);
  ACE_Token_Proxy *temp;
  // Get the token from the collection.
  int result = collection_.find (name, temp);
  // did we find it?
  if (result == -1)
    return result;

  // perform the operation
  return temp->tryacquire (sleep_hook);
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:16,代码来源:Token_Collection.cpp

示例6: run_thread

static void *
run_thread (void *vp)
{
    ACE_Token_Proxy *collection = (ACE_Token_Proxy *) vp;

    int count = iterations;
    while (count--)
    {
        if (collection->acquire () == -1)
        {
            if (ACE_OS::last_error () == EDEADLK)
            {
                ACE_DEBUG ((LM_DEBUG, "deadlock detected in acquire"));
                continue;
            }
            ACE_ERROR ((LM_ERROR, "(%t) %p acquire failed\n","run_thread"));
            return (void *) -1;
        }

        ACE_DEBUG ((LM_DEBUG, "(%t) %s acquired.\n", collection->name ()));

        if (collection->renew () == -1)
        {
            if (ACE_OS::last_error () == EDEADLK)
            {
                ACE_DEBUG ((LM_DEBUG, "deadlock detected"));
                goto deadlock;
            }
            ACE_ERROR ((LM_ERROR, "(%t) %p renew failed\n","run_thread"));
            return (void *) -1;
        }

        ACE_DEBUG ((LM_DEBUG, "(%t) %s renewed.\n", collection->name ()));

deadlock:
        if (collection->release () == -1)
        {
            ACE_ERROR ((LM_ERROR, "(%t) %p release failed\n","run_thread"));
            return (void *) -1;
        }

        ACE_DEBUG ((LM_DEBUG, "(%t) %s released.\n", collection->name ()));
    }

    ACE_DEBUG ((LM_DEBUG, "(%t) thread exiting.\n"));
    return 0;
}
开发者ID:asdlei00,项目名称:ACE,代码行数:47,代码来源:collection.cpp

示例7: ACE_UNUSED_ARG

int
STDIN_Token::handle_input (ACE_HANDLE fd)
{
  ACE_UNUSED_ARG (fd);

  char tid[BUFSIZ];
  char token[BUFSIZ];
  char type[16];
  char operation[16];

  if (::scanf ("%s %s %s %s", tid, token, type, operation) <= 0)
    {
      ACE_OS::printf ("Try again.\n");
      return 0;
    }

  ACE_Token_Proxy *proxy =
    this->get_proxy (tid, token, type[0]);

  if (proxy == 0)
    return -1;

  switch (operation[0])
    {
    case 'a':
    case 'A':
      if (proxy->acquire () == 0)
        {
          ACE_OS::printf ("Succeeded.\n");
          if (ACE_TOKEN_INVARIANTS::instance ()->acquired (proxy) == 0)
            ACE_OS::printf ("Violated invariant.\n");
        }
      else
        ACE_ERROR ((LM_ERROR, "%p.\n", "Acquire failed"));
      break;
    case 'n':
    case 'N':
      ACE_TOKEN_INVARIANTS::instance ()->releasing (proxy);
      if (proxy->renew () == 0)
        {
          ACE_OS::printf ("Succeeded.\n");
          if (ACE_TOKEN_INVARIANTS::instance ()->acquired (proxy) == 0)
            ACE_OS::printf ("Violated invariant.\n");
        }
      else
        ACE_ERROR ((LM_ERROR, "%p.\n", "Renew failed"));
      break;

    case 'r':
    case 'R':
      ACE_TOKEN_INVARIANTS::instance ()->releasing (proxy);
      if (proxy->release () == 0)
        ACE_OS::printf ("Succeeded.\n");
      else
        ACE_ERROR ((LM_ERROR, "%p.\n", "Release failed"));
      break;

    case 't':
    case 'T':
      if (proxy->tryacquire () == 0)
        {
          ACE_OS::printf ("Succeeded.\n");
          if (ACE_TOKEN_INVARIANTS::instance ()->acquired (proxy) == 0)
            ACE_OS::printf ("Violated invariant.\n");
        }
      else
        ACE_ERROR ((LM_ERROR, "%p.\n", "Tryacquire failed"));
      break;
    }

  this->display_menu ();
  return 0;
}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:73,代码来源:manual.cpp


注:本文中的ACE_Token_Proxy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。