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


C++ ACE_SET_BITS函数代码示例

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

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

示例1: ACE_TRACE

template <ACE_SYNCH_DECL> int
ACE_Module<ACE_SYNCH_USE>::open (const ACE_TCHAR *module_name,
                                 ACE_Task<ACE_SYNCH_USE> *writer_q,
                                 ACE_Task<ACE_SYNCH_USE> *reader_q,
                                 void *arg,
                                 int flags /* = M_DELETE */)
{
    ACE_TRACE ("ACE_Module<ACE_SYNCH_USE>::open");
    this->name (module_name);
    this->arg_ = arg;

    // We may already have readers and/or writers.
    if (this->reader ())
        this->close_i (0, M_DELETE_READER);

    if (this->writer ())
        this->close_i (1, M_DELETE_WRITER);

    if (writer_q == 0)
    {
        ACE_NEW_RETURN (writer_q,
                        ACE_Thru_Task<ACE_SYNCH_USE>,
                        -1);
        ACE_SET_BITS (flags, M_DELETE_WRITER);
    }

    if (reader_q == 0)
    {
        ACE_NEW_RETURN (reader_q,
                        ACE_Thru_Task<ACE_SYNCH_USE>,
                        -1);
        ACE_SET_BITS (flags, M_DELETE_READER);
    }

    this->reader (reader_q);
    this->writer (writer_q);

    // Save the flags
    this->flags_ = flags;

    // Make sure that the memory is allocated before proceding.
    if (writer_q == 0 || reader_q == 0)
    {
        // These calls will delete writer_q and/or reader_q, if
        // necessary.
        this->close_i (0, M_DELETE_READER);
        this->close_i (1, M_DELETE_WRITER);

        errno = ENOMEM;
        return -1;
    }

    // Setup back pointers (this must come last, after we've made sure
    // there's memory allocated here.
    reader_q->mod_ = this;
    writer_q->mod_ = this;

    return 0;
}
开发者ID:Xadras,项目名称:TBCPvP,代码行数:59,代码来源:Module.cpp


示例2: ACE_BIT_ENABLED

int
ACE_Log_Msg_UNIX_Syslog::convert_log_mask (int lm_mask)
{
  int syslog_mask = 0;

  if (ACE_BIT_ENABLED (lm_mask, LM_TRACE)
      || ACE_BIT_ENABLED (lm_mask, LM_DEBUG))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_DEBUG));

  if (ACE_BIT_ENABLED (lm_mask, LM_STARTUP)
      || ACE_BIT_ENABLED (lm_mask, LM_SHUTDOWN)
      || ACE_BIT_ENABLED (lm_mask, LM_INFO))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_INFO));

  if (ACE_BIT_ENABLED (lm_mask, LM_NOTICE))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_NOTICE));

  if (ACE_BIT_ENABLED (lm_mask, LM_ERROR))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ERR));

  if (ACE_BIT_ENABLED (lm_mask, LM_WARNING))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_WARNING));

  if (ACE_BIT_ENABLED (lm_mask, LM_CRITICAL))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_CRIT));

  if (ACE_BIT_ENABLED (lm_mask, LM_ALERT))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_ALERT));

  if (ACE_BIT_ENABLED (lm_mask, LM_EMERGENCY))
    ACE_SET_BITS (syslog_mask, LOG_MASK(LOG_EMERG));

  return syslog_mask;
}
开发者ID:Denominator13,项目名称:NeoCore,代码行数:34,代码来源:Log_Msg_UNIX_Syslog.cpp


示例3: ACE_SET_BITS

int
Priority_Task::open (void *arg)
{
  this->priority_ = *(int *) arg;

  long flags = THR_NEW_LWP;

  // To get FIFO scheduling with PTHREADS.
  ACE_SET_BITS (flags,
                THR_SCHED_FIFO);

  // Become an active object.
  if (this->activate (flags,
                      1,
                      0,
                      this->priority_) == -1)
    {
      // On Linux, for example, only the superuser can set the policy
      // to other than ACE_SCHED_OTHER.  But with ACE_SCHED_OTHER,
      // there is only one thread priority value, for example, 0.  So,
      // let the superuser run an interesting test, but for other
      // users use the minimum ACE_SCHED_OTHER thread priority.

      long fallback_priority =
        ACE_Sched_Params::priority_min (ACE_SCHED_OTHER,
                                        ACE_SCOPE_THREAD);

      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("(%t) task activation at priority %d with ")
                  ACE_TEXT ("flags 0x%X failed; retry at priority %d with ")
                  ACE_TEXT ("flags 0x%X (errno is %d%p)\n"),
                  this->priority_,
                  flags,
                  fallback_priority,
                  THR_NEW_LWP,
                  ACE_ERRNO_GET,
                  ACE_TEXT ("")));

      flags = THR_NEW_LWP;
      this->priority_ = fallback_priority;

      if (this->activate (flags,
                          1,
                          1,
                          this->priority_) == -1)
        {
          if (ACE_OS::last_error () == EPERM)
            ACE_ERROR_RETURN ((LM_INFO,
                               ACE_TEXT ("Insufficient privilege to run this test.\n")),
                              -1);
          else
            ACE_DEBUG ((LM_ERROR,
                        ACE_TEXT ("(%t) task activation at priority %d failed, ")
                        ACE_TEXT ("exiting!\n%a"),
                        this->priority_,
                        -1));
        }
    }
  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:60,代码来源:Priority_Task_Test.cpp


示例4: ACE_TRACE

int
ACE_Flag_Manip::set_flags (ACE_HANDLE handle, int flags)
{
  ACE_TRACE ("ACE_Flag_Manip::set_flags");
#if defined (ACE_WIN32) || defined (VXWORKS) || defined (ACE_LACKS_FCNTL)
  switch (flags)
    {
    case ACE_NONBLOCK:
      // nonblocking argument (1)
      // blocking:            (0)
      {
        u_long nonblock = 1;
        return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
      }
    default:
      ACE_NOTSUP_RETURN (-1);
    }
#else
  int val = ACE_OS::fcntl (handle, F_GETFL, 0);

  if (val == -1)
    return -1;

  // Turn on flags.
  ACE_SET_BITS (val, flags);

  if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
    return -1;
  else
    return 0;
#endif /* ACE_WIN32 || ACE_LACKS_FCNTL */
}
开发者ID:xkmld419,项目名称:crawl,代码行数:32,代码来源:Flag_Manip.cpp


示例5: ACE_TEXT

void
ACE_Logging_Strategy::tokenize (ACE_TCHAR *flag_string)
{
  ACE_TCHAR *strtokp;

  for (ACE_TCHAR *flag = ACE_OS::strtok_r (flag_string,
                                           ACE_TEXT ("|"),
                                           &strtokp);
       flag != 0;
       flag = ACE_OS::strtok_r (0, ACE_TEXT ("|"), &strtokp))
    {
      if (ACE_OS::strcmp (flag, ACE_TEXT ("STDERR")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::STDERR);
      else if (ACE_OS::strcmp (flag, ACE_TEXT ("LOGGER")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER);
      else if (ACE_OS::strcmp (flag, ACE_TEXT ("OSTREAM")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM);
      else if (ACE_OS::strcmp (flag, ACE_TEXT ("VERBOSE")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE);
      else if (ACE_OS::strcmp (flag, ACE_TEXT ("VERBOSE_LITE")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::VERBOSE_LITE);
      else if (ACE_OS::strcmp (flag, ACE_TEXT ("SILENT")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::SILENT);
      else if (ACE_OS::strcmp (flag, ACE_TEXT ("SYSLOG")) == 0)
        ACE_SET_BITS (this->flags_, ACE_Log_Msg::SYSLOG);
    }
}
开发者ID:eSDK,项目名称:esdk_Cgw,代码行数:27,代码来源:Logging_Strategy.cpp


示例6: defined

int
Globals::sched_fifo_init (void)
{
#if defined (ACE_HAS_THREADS)
  // Enable FIFO scheduling, e.g., RT scheduling class on Solaris.
# if defined (_AIX) || defined (__APPLE__) || defined (BSD)
  int scope = ACE_SCOPE_THREAD;
# else
  int scope = ACE_SCOPE_PROCESS;
# endif /* _AIX */

  if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO,
                                              SCHED_PRIORITY,
                                              scope)))
    {
      if (ACE_OS::last_error () == EPERM)
        {
          ACE_DEBUG ((LM_MAX,
                      "User is not superuser, "
                      "so remain in time-sharing class\n"));
          ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_NEW_LWP);
          GLOBALS::instance ()->default_priority = ACE_THR_PRI_OTHER_DEF;
          return 1;
        }
      else
        ACE_ERROR_RETURN ((LM_ERROR,
                           "%n: ACE_OS::sched_params failed\n%a"),
                          -1);
    }

  ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_BOUND);
  ACE_SET_BITS (GLOBALS::instance ()->thr_create_flags, THR_SCHED_FIFO);
  GLOBALS::instance ()->default_priority = ACE_THR_PRI_FIFO_DEF;

  return 0;
#else

  ACE_ERROR_RETURN ((LM_ERROR,
                     "Test will not run.  This platform doesn't seem to have threads.\n"),
                    -1);
#endif /* ACE_HAS_THREADS */
}
开发者ID:CCJY,项目名称:ATCD,代码行数:42,代码来源:Globals.cpp


示例7: ACE_SET_BITS

int
Sender::initiate_io (ACE_Reactor_Mask mask)
{
  if (ACE_BIT_ENABLED (flg_mask_, mask))
    return 0;

  if (ACE_Reactor::instance ()->schedule_wakeup (this, mask) == -1)
    return -1;

  ACE_SET_BITS (flg_mask_, mask);
  return 0;
}
开发者ID:azraelly,项目名称:knetwork,代码行数:12,代码来源:TP_Reactor_Test.cpp


示例8: ACE_TRACE

int
ACE_FoxReactor::remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask)
{
  ACE_TRACE ("ACE_FoxReactor::remove_handler_i");

  // In the registration phase we registered first with
  // ACE_Select_Reactor and then with X.  Now we are now doing things
  // in reverse order.

  int condition = 0;

  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, FX::INPUT_READ);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, FX::INPUT_WRITE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
    ACE_SET_BITS (condition, FX::INPUT_EXCEPT);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
    ACE_SET_BITS (condition, FX::INPUT_READ);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
    {
      ACE_SET_BITS (condition, FX::INPUT_WRITE); // connected, you may write
      ACE_SET_BITS (condition, FX::INPUT_READ);  // connected, you have data/err
    }

  // First clean up the corresponding X11Input.
  fxapp->removeInput ((int)handle,condition); // ACE_reinterpret_cast(int,handle));

  // Now let the reactor do its work.
  return ACE_Select_Reactor::remove_handler_i (handle, mask);
}
开发者ID:07jkim,项目名称:TrinityCore,代码行数:31,代码来源:FoxReactor.cpp


示例9: ACE_TRACE

int
ACE_XtReactor::compute_Xt_condition(ACE_HANDLE handle)
{
  ACE_TRACE ("ACE_XtReactor::compute_Xt_condition");

  // Retrieve current wait mask from base class.
  // The returned value is either a combination of READ/WRITE/EXCEPT_MASK
  // or -1.
  int mask =this->bit_ops(handle,
                          0,
                          this->wait_set_,
                          ACE_Reactor::GET_MASK);

  if (mask == -1) // No active mask.
    return 0;

 int condition = 0;

#if !defined ACE_WIN32
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, XtInputReadMask);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, XtInputWriteMask);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
    ACE_SET_BITS (condition, XtInputExceptMask);
#else
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, XtInputReadWinsock);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, XtInputWriteWinsock);
  // EXCEPT_MASK is not supported for WIN32. As this was
  // already handled in register_handler_i, no check here.
#endif /* !ACE_WIN32 */

  return condition;
}
开发者ID:AlexHjelm,项目名称:sunwell,代码行数:36,代码来源:XtReactor.cpp


示例10: ACE_SET_BITS

void
ACE_Synch_Options::set (unsigned long options,
                        const ACE_Time_Value &timeout,
                        const void *arg)
{
  // ACE_TRACE ("ACE_Synch_Options::set");
  this->options_ = options;
  this->timeout_ = timeout;

  // Whoa, possible dependence on static initialization here.  This
  // function is called during initialization of the statics above.
  // But, ACE_Time_Value::zero is a static object.  Very fortunately,
  // its bits have a value of 0.
  if (this->timeout_ != ACE_Time_Value::zero)
    ACE_SET_BITS (this->options_, ACE_Synch_Options::USE_TIMEOUT);

  this->arg_ = arg;
}
开发者ID:08keelr,项目名称:TrinityCore,代码行数:18,代码来源:Synch_Options.cpp


示例11: ACE_DEBUG

int KSG_Service_Handler::open()
{
	this->request_time_ = ACE_OS::gettimeofday();
	this->connect_time_ = this->request_time_;
	char val[2] = "";
	int len = 1;
	val[0] = 0x1;
	if(ACE_OS::setsockopt(peer().get_handle(),SOL_SOCKET,TCP_NODELAY,val,len)!=0)
		ACE_DEBUG((LM_ERROR,"创建新连接,设置属性失败"));
	// 准备读取数据
	if(this->reactor()->register_handler(this,ACE_Event_Handler::READ_MASK))
	{
		ACE_DEBUG((LM_ERROR,"注册侦听句柄失败"));
		return -1;
	}
	ACE_Time_Value reschedule (max_client_timeout_.sec () / 4);
	reactor()->schedule_timer(this,0,max_client_timeout_,reschedule);
	ACE_SET_BITS(this->mask_,ACE_Event_Handler::READ_MASK);
	return 0;
}
开发者ID:nykma,项目名称:ykt4sungard,代码行数:20,代码来源:reactor_def.cpp


示例12: ACE_TRACE

template <ACE_SYNCH_DECL, class TIME_POLICY> void
ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer (ACE_Task<ACE_SYNCH_USE, TIME_POLICY> *q,
                                   int flags /* = M_DELETE_WRITER */)
{
  ACE_TRACE ("ACE_Module<ACE_SYNCH_USE, TIME_POLICY>::writer");

  // Close and maybe delete old writer
  this->close_i (1, flags);

  this->q_pair_[1] = q;

  if (q != 0)
    {
      ACE_CLR_BITS (q->flags_, ACE_Task_Flags::ACE_READER);
      // Set the q's module pointer to point to us.
      q->mod_ = this;
    }

  // Don't allow the caller to change the reader status.
  ACE_SET_BITS (flags_, (flags & M_DELETE_WRITER));
}
开发者ID:Bootz,项目名称:SkyFire_one,代码行数:21,代码来源:Module.cpp


示例13: ACE_TRACE

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

// Flags are file status flags to turn on.

int
ACE::set_flags (ACE_HANDLE handle, int flags)
{
  ACE_TRACE ("ACE::set_flags");
#if defined (ACE_LACKS_FCNTL)
  switch (flags)
    {
    case ACE_NONBLOCK:
      // nonblocking argument (1)
      // blocking:            (0)
      {
        int nonblock = 1;
        return ACE_OS::ioctl (handle, FIONBIO, &nonblock);
      }
    default:
      ACE_NOTSUP_RETURN (-1);
    }
#else
  int val = ACE_OS::fcntl (handle, F_GETFL, 0);

  if (val == -1)
    return -1;

  // Turn on flags.
  ACE_SET_BITS (val, flags);

  if (ACE_OS::fcntl (handle, F_SETFL, val) == -1)
    return -1;
  else
    return 0;
#endif /* ACE_LACKS_FCNTL */
}
开发者ID:CCJY,项目名称:ACE,代码行数:36,代码来源:Flag_Manip.cpp


示例14: getopt


//.........这里部分代码省略.........
          {
            int n = ACE_OS::atoi (getopt.opt_arg ());
            // I'm assuming 0 means unlimited, so just use whatever the
            // user provides.  Seems to work okay on Solaris 5.8.
            if (IP_MAX_MEMBERSHIPS == 0)
              this->groups_ = n;
            else
              this->groups_ = ACE_MIN (ACE_MAX (n, MCT_MIN_GROUPS),
                                       IP_MAX_MEMBERSHIPS);
            break;
          }
        case 'd':
          this->debug_ = 1;
          break;
        case 'r':
          {
            ACE_TCHAR *c = getopt.opt_arg ();
            if (ACE_OS::strcasecmp (c, ACE_TEXT ("CONSUMER")) == 0)
              this->role_ = CONSUMER;
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("PRODUCER")) == 0)
              this->role_ = PRODUCER;
            else
              {
                help = 1;
                retval = -1;
              }
          }
          break;
        case 'm':
          {
            //@todo add back OPT_BINDADDR_NO...
            ACE_TCHAR *c = getopt.opt_arg ();
            if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_YES")) == 0)
              ACE_SET_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_BINDADDR_NO")) == 0)
              ACE_CLR_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_BINDADDR")) == 0)
              {
                ACE_CLR_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::OPT_BINDADDR_YES);
                ACE_SET_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::DEFOPT_BINDADDR);
              }
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ALL")) == 0)
              ACE_SET_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("OPT_NULLIFACE_ONE")) == 0)
              ACE_CLR_BITS (this->sdm_opts_,
                            ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL);
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPT_NULLIFACE")) == 0)
              {
                ACE_CLR_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::OPT_NULLIFACE_ALL);
                ACE_SET_BITS (this->sdm_opts_,
                              ACE_SOCK_Dgram_Mcast::DEFOPT_NULLIFACE);
              }
            else if (ACE_OS::strcasecmp (c, ACE_TEXT ("DEFOPTS")) == 0)
              this->sdm_opts_ = ACE_SOCK_Dgram_Mcast::DEFOPTS;
            else
              {
                help = 1;
                retval = -1;
              }
          }
开发者ID:CCJY,项目名称:ACE,代码行数:67,代码来源:Multicast_Test.cpp


示例15: ACE_TRACE

int
ACE_TkReactor::register_handler_i (ACE_HANDLE handle,
                                   ACE_Event_Handler *handler,
                                   ACE_Reactor_Mask mask)
{
  ACE_TRACE ("ACE_TkReactor::register_handler_i");

  int result = ACE_Select_Reactor::register_handler_i (handle,
                                                       handler, mask);
  if (result == -1)
    return -1;

  int condition = 0;

#if !defined ACE_WIN32
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, TK_READABLE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, TK_WRITABLE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
    ACE_SET_BITS (condition, TK_EXCEPTION);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
    ACE_SET_BITS (condition, TK_READABLE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){
      ACE_SET_BITS (condition, TK_READABLE); // connected, you may write
      ACE_SET_BITS (condition, TK_WRITABLE);  // connected, you have data/err
  }
#else
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, TK_READABLE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, TK_WRITABLE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
    ACE_NOTSUP_RETURN(-1);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
    ACE_SET_BITS (condition, TK_READABLE);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){
      ACE_SET_BITS (condition, TK_READABLE); // connected, you may write
      ACE_SET_BITS (condition, TK_WRITABLE);  // connected, you have data/err
  }
#endif /* !ACE_WIN32 */

  if (condition != 0)
    {
      ACE_TkReactorID *TkID = this->ids_;

      while(TkID)
        {
          if (TkID->handle_ == handle)
            {
              ::Tk_DeleteFileHandler (TkID->handle_);

              ACE_TkReactor_Input_Callback *callback;
              ACE_NEW_RETURN (callback,
                              ACE_TkReactor_Input_Callback,
                              -1);
              callback->reactor_ = this;
              callback->handle_ = handle;
              ::Tk_CreateFileHandler ((int) handle,
                                      condition,
                                      InputCallbackProc,
                                      (ClientData) callback);
              return 0;
            }
          else
            TkID = TkID->next_;
        }

      ACE_NEW_RETURN (TkID,
                      ACE_TkReactorID,
                      -1);
      TkID->next_ = this->ids_;
      TkID->handle_ = handle;
      ACE_TkReactor_Input_Callback *callback;
      ACE_NEW_RETURN (callback,
                      ACE_TkReactor_Input_Callback,
                      -1);
      callback->reactor_ = this;
      callback->handle_ = handle;

      ::Tk_CreateFileHandler ((int) handle,
                              condition,
                              InputCallbackProc,
                              (ClientData) callback);
      this->ids_ = TkID;
    }
  return 0;
}
开发者ID:CCJY,项目名称:ACE,代码行数:88,代码来源:TkReactor.cpp


示例16: ACE_TRACE

int
ACE_Logging_Strategy::parse_args (int argc, ACE_TCHAR *argv[])
{
  ACE_TRACE ("ACE_Logging_Strategy::parse_args");
  ACE_TCHAR *temp;

  // Perform data member initializations.  BTW, do *not* initialize
  // <thread_priority_mask_> or <process_priority_mask_> here to avoid
  // unduing the behavior in <init>, where these are set by
  // <ACE_Log_Msg::instance>.
  this->flags_ = 0;
  this->wipeout_logfile_ = false;
  this->count_ = 0;
  this->fixed_number_ = false;
  this->order_files_ = false;
  this->max_file_number_ = 1;
  this->interval_ = ACE_DEFAULT_LOGFILE_POLL_INTERVAL;
  this->max_size_ = 0;

  ACE_Get_Opt get_opt (argc, argv,
                       ACE_TEXT ("f:i:k:m:n:N:op:s:t:w"), 0);

  for (int c; (c = get_opt ()) != -1; )
    {
      switch (c)
        {
        case 'f':
          temp = get_opt.opt_arg ();
          // Now tokenize the string to get all the flags
          this->tokenize (temp);
          // If LOGGER was specified, set up the default logger key.
          // The key can be changed by the -k option also, so if it's
          // been set already, don't set it.
          if (ACE_BIT_ENABLED (this->flags_, ACE_Log_Msg::LOGGER) &&
              this->logger_key_ == 0)
            this->logger_key_ = ACE::strnew (ACE_DEFAULT_LOGGER_KEY);
          break;
        case 'i':
          // Interval (in secs) at which logfile size is sampled.
          this->interval_ = ACE_OS::strtoul (get_opt.opt_arg (), 0, 10);
          break;
        case 'k':
          // Ensure that the LOGGER flag is set
          ACE_SET_BITS (this->flags_, ACE_Log_Msg::LOGGER);
          delete [] this->logger_key_;
          this->logger_key_ = ACE::strnew (get_opt.opt_arg ());
          break;
        case 'm':
          // Maximum logfile size (in KB).  Must be a non-zero value.
          this->max_size_ = ACE_OS::strtoul (get_opt.opt_arg (), 0, 10);
          this->max_size_ <<= 10;       // convert from KB to bytes.
          break;
        case 'n':
          delete [] this->program_name_;
          this->program_name_ = ACE::strnew (get_opt.opt_arg ());
          break;
        case 'N':
          // The max number for the log_file being created
          this->max_file_number_ = ACE_OS::atoi (get_opt.opt_arg ()) - 1;
          this->fixed_number_ = true;
          break;
        case 'o':
          // Log_files generation order
          this->order_files_ = true;
          break;
        case 'p':
          temp = get_opt.opt_arg ();
          // Now tokenize the string to setup process log priority
          this->priorities (temp, ACE_Log_Msg::PROCESS);
          break;
        case 's':
          // Ensure that the OSTREAM flag is set
          ACE_SET_BITS (this->flags_, ACE_Log_Msg::OSTREAM);
          delete [] this->filename_;
          this->filename_ = ACE::strnew (get_opt.opt_arg ());
          break;
        case 't':
          temp = get_opt.opt_arg ();
          // Now tokenize the string to setup thread log priority
          this->priorities (temp, ACE_Log_Msg::THREAD);
          break;
        case 'w':
          // Cause the logfile to be wiped out, both on startup and on
          // reconfigure.
          this->wipeout_logfile_ = true;
          break;
        default:
          break;
        }
    }
  return 0;
}
开发者ID:eSDK,项目名称:esdk_Cgw,代码行数:92,代码来源:Logging_Strategy.cpp


示例17: ACE_TRACE

int
ACE_Service_Gestalt::open_i (const ACE_TCHAR program_name[],
                             const ACE_TCHAR* logger_key,
                             bool ignore_static_svcs,
                             bool ignore_default_svc_conf_file,
                             bool ignore_debug_flag)
{
  ACE_TRACE ("ACE_Service_Gestalt::open_i");
  int result = 0;
  ACE_Log_Msg *log_msg = ACE_LOG_MSG;

  this->no_static_svcs_ = ignore_static_svcs;

  // Record the current log setting upon entering this thread.
  u_long old_process_mask = log_msg->priority_mask
    (ACE_Log_Msg::PROCESS);

  u_long old_thread_mask = log_msg->priority_mask
    (ACE_Log_Msg::THREAD);

#ifndef ACE_NLOGGING
  if (ACE::debug ())
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("ACE (%P|%t) SG::open_i - this=%@, ")
                ACE_TEXT ("opened=%d, loadstatics=%d\n"),
                this, this->is_opened_, this->no_static_svcs_));
#endif

  // Guard against reentrant processing. For example,
  // if the singleton gestalt (ubergestalt) was already open,
  // do not open it again...
  if (this->is_opened_++ != 0)
    return 0;

  if (this->init_i () != 0)
    return -1;

  u_long flags = log_msg->flags ();

  // Only use STDERR if the caller hasn't already set the flags.
  if (flags == 0)
    flags = (u_long) ACE_Log_Msg::STDERR;

  const ACE_TCHAR *key = logger_key;

  if (key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0)
    {
      // Only use the static <logger_key_> if the caller doesn't
      // override it in the parameter list or if the key supplied is
      // equal to the default static logger key.
      key = this->logger_key_;
    }
  else
    {
      ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER);
    }

  if (log_msg->open (program_name,
                     flags,
                     key) == -1)
    return -1;

  if (!ignore_debug_flag)
    {
      // If -d was included as a startup parameter, the user wants debug
      // information printed during service initialization.
      if (ACE::debug ())
        ACE_Log_Msg::enable_debug_messages ();
      else
        // The user has requested no debugging info.
        ACE_Log_Msg::disable_debug_messages ();
    }

  // See if we need to load the static services.
  if (this->no_static_svcs_ == 0
      && this->load_static_svcs () == -1)
    result = -1;
  else
    {
      if (this->process_directives (ignore_default_svc_conf_file) == -1)
        result = -1;
      else
        result = this->process_commandline_directives ();
    }


  // Reset debugging back to the way it was when we came into
  // into <open_i>.
  {
    // Make sure to save/restore errno properly.
    ACE_Errno_Guard error (errno);

    if (!ignore_debug_flag)
      {
        log_msg->priority_mask (old_process_mask, ACE_Log_Msg::PROCESS);
        log_msg->priority_mask (old_thread_mask, ACE_Log_Msg::THREAD);
      }
  }

  return result;
//.........这里部分代码省略.........
开发者ID:Archives,项目名称:ro_core,代码行数:101,代码来源:Service_Gestalt.cpp


示例18: ACE_TRACE

int
ACE_XtReactor::register_handler_i (ACE_HANDLE handle,
                                   ACE_Event_Handler *handler,
                                   ACE_Reactor_Mask mask)
{
  ACE_TRACE ("ACE_XtReactor::register_handler_i");

  // Make sure we have a valid context
  ACE_ASSERT (this->context_ != 0);

  int result = ACE_Select_Reactor::register_handler_i (handle,
                                                       handler, mask);
  if (result == -1)
    return -1;

  int condition = 0;

#if !defined ACE_WIN32
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, XtInputReadMask);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, XtInputWriteMask);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
    ACE_SET_BITS (condition, XtInputExceptMask);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
    ACE_SET_BITS (condition, XtInputReadMask);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){
      ACE_SET_BITS (condition, XtInputWriteMask); // connected, you may write
      ACE_SET_BITS (condition, XtInputReadMask);  // connected, you have data/err
  }
#else
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK))
    ACE_SET_BITS (condition, XtInputReadWinsock);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK))
    ACE_SET_BITS (condition, XtInputWriteWinsock);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
    ACE_NOTSUP_RETURN(-1);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
    ACE_SET_BITS (condition, XtInputReadWinsock);
  if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){
      ACE_SET_BITS (condition, XtInputWriteWinsock); // connected, you may write
      ACE_SET_BITS (condition, XtInputReadWinsock);  // connected, you have data/err
  }
#endif /* !ACE_WIN32 */

  if (condition != 0)
    {
      ACE_XtReactorID *XtID = this->ids_;

      while(XtID)
        {
          if (XtID->handle_ == handle)
            {
              ::XtRemoveInput (XtID->id_);

              XtID->id_ = ::XtAppAddInput (this->context_,
                                           (int) handle,
                                           (XtPointer) condition,
                                           InputCallbackProc,
                                           (XtPointer) this);
              return 0;
            }
          else
            XtID = XtID->next_;
        }

      ACE_NEW_RETURN (XtID,
                      ACE_XtReactorID,
                      -1);
      XtID->next_ = this->ids_;
      XtID->handle_ = handle;
      XtID->id_ = ::XtAppAddInput (this->context_,
                                  (int) handle,
                                  (XtPointer) condition,
                                  InputCallbackProc,
                                  (XtPointer) this);
      this->ids_ = XtID;
    }
  return 0;
}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:80,代码来源:XtReactor.cpp


示例19: ACE_TRACE

int
ACE_Service_Config::open_i (const ACE_TCHAR program_name[],
                            const ACE_TCHAR *logger_key,
                            bool ,
                            bool ,
                            bool )
{
  ACE_TRACE ("ACE_Service_Config::open_i");
  ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));

  ACE_Log_Msg *log_msg = ACE_LOG_MSG;

  if(ACE::debug ())
    ACE_DEBUG ((LM_DEBUG,
                ACE_TEXT ("ACE (%P|%t) SC::open_i - this=%@, opened=%d\n"),
                this, this->is_opened_));

  // Guard against reentrant processing.
  if(this->is_opened_)
    return 0;

  this->is_opened_ = true;

  // Check for things we need to do on a per-process basis and which
  // may not be safe, or wise to do an a per instance basis

  // Become a daemon before doing anything else.
  if(ACE_Service_Config::be_a_daemon_)
    ACE::daemonize ();

  // Write process id to file.
  if(this->pid_file_name_ != 0)
    {
      FILE* pidf = ACE_OS::fopen (this->pid_file_name_,
                                  ACE_TEXT("w"));

      if(pidf != 0)
        {
          ACE_OS::fprintf (pidf,
                           "%ld\n",
                           static_cast<long> (ACE_OS::getpid()));
          ACE_OS::fclose (pidf);
        }
    }

  u_long flags = log_msg->flags ();

  // Only use STDERR if the caller hasn't already set the flags.
  if(flags == 0)
    flags = (u_long) ACE_Log_Msg::STDERR;

  const ACE_TCHAR *key = logger_key;

  if(key == 0 || ACE_OS::strcmp (key, ACE_DEFAULT_LOGGER_KEY) == 0)
    {
      // Only use the static <logger_key_> if the caller doesn't
      // override it in the parameter list or if the key supplied is
      // equal to the default static logger key.
      key = ACE_Service_Config::current()->logger_key_;
    }
  else
    {
      ACE_SET_BITS (flags, ACE_Log_Msg::LOGGER);
    }

  if(log_msg->open (program_name,
                     flags,
                     key) == -1)
    return -1;

  if(ACE::debug ())
    ACE_DEBUG ((LM_STARTUP,
                ACE_TEXT ("starting up daemon %n\n")));

  // Initialize the Service Repository (this will still work if
  // user forgets to define an object of type ACE_Service_Config).
  ACE_Service_Repository::instance (ACE_Service_Gestalt::MAX_SERVICES);

  // Initialize the ACE_Reactor (the ACE_Reactor should be the
  // same size as the ACE_Service_Repository).
  ACE_Reactor::instance ();

  // There's no point in dealing with this on NT since it doesn't
  // really support signals very well...
#if !defined (ACE_LACKS_UNIX_SIGNALS)
  // Only attempt to register a signal handler for positive
  // signal numbers.
  if(ACE_Service_Config::signum_ > 0)
    {
      ACE_Sig_Set ss;
      ss.sig_add (ACE_Service_Config::signum_);
      if((ACE_Reactor::instance () != 0) &&
          (ACE_Reactor::instance ()->register_handler
           (ss, ACE_Service_Config::signal_handler_) == -1))
        ACE_ERROR ((LM_ERROR,
                    ACE_TEXT ("can't register signal handler\n")));
    }
#endif /* ACE_LACKS_UNIX_SIGNALS */

  return 0;
//.........这里部分代码省略.........
开发者ID:Desch,项目名称:MythCore,代码行数:101,代码来源:Service_Config.cpp


示例20: base_addr_

ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool (
  const ACE_TCHAR *backing_store_name,
  const OPTIONS *options)
  : base_addr_ (0),
    use_fixed_addr_(0),
    flags_ (MAP_SHARED),
    write_each_page_ (false),
    minimum_bytes_ (0),
    sa_ (0),
    file_mode_ (ACE_DEFAULT_FILE_PERMS),
    install_signal_handler_ (true)
{
  ACE_TRACE ("ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool");

#if (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32)
      // For plaforms that give the faulting address.
      guess_on_fault_ = false;
#else
      // For plaforms that do NOT give the faulting address, let the
      // options decide whether to guess or not.
      if (options)
        guess_on_fault_ = options->guess_on_fault_;
      else
        // If no options are specified, default to true.
        guess_on_fault_ = true;
#endif /* (defined (ACE_HAS_SIGINFO_T) && !defined (ACE_LACKS_SI_ADDR)) || defined (ACE_WIN32) */

  // Only change the defaults if <options> != 0.
  if (options)
    {
      if (options->flags_ != 0)
        this->flags_ = options->flags_;
      use_fixed_addr_ = options->use_fixed_addr_;

      if (use_fixed_addr_ == ACE_MMAP_Memory_Pool_Options::ALWAYS_FIXED)
        {
          this->base_addr_ = const_cast<void *> (options->base_addr_);
          ACE_SET_BITS (flags_, MAP_FIXED);
        }
      this->write_each_page_ = options->write_each_page_;
      this->minimum_bytes_ = options->minimum_bytes_;
      if (options->sa_ != 0)
        this->sa_ = options->sa_;
      this->file_mode_ = options->file_mode_;
      this->install_signal_handler_ = options->install_signal_handler_;
    }

  if (backing_store_name == 0)
    {
      // Only create a new unique filename for the backing store file
      // if the user didn't supply one...
#if defined (ACE_DEFAULT_BACKING_STORE)
      // Create a temporary file.
      ACE_OS::strcpy (this->backing_store_name_,
                      ACE_DEFAULT_BACKING_STORE);
#else /* ACE_DEFAULT_BACKING_STORE */
      if (ACE::get_temp_dir (this->backing_store_name_,
                             MAXPATHLEN - 17) == -1)
        // -17 for ace-malloc-XXXXXX
        {
          ACELIB_ERROR ((LM_ERROR,
                      ACE_TEXT ("Temporary path too long, ")
                      ACE_TEXT ("defaulting to current directory\n")));
          this->backing_store_name_[0] = 0;
        }

      // Add the filename to the end
      ACE_OS::strcat (this->backing_store_name_,
                      ACE_TEXT ("ace-malloc-XXXXXX"));

      // If requested an unique filename, use mktemp to get a random file.
      if (options && options->unique_)
#  if defined (ACE_DISABLE_MKTEMP)
        {
          ACELIB_ERROR ((LM_ERROR,
                         ACE_TEXT ("mktemp disabled; ")
                         ACE_TEXT ("can't generate unique name")));
          this->backing_store_name_[0] = 0;
        }
#  else
        ACE_OS::mktemp(this->backing_store_name_);
#  endif /* ACE_DISABLE_MKTEMP */
#endif /* ACE_DEFAULT_BACKING_STORE */
    }
  else
    ACE_OS::strsncpy (this->backing_store_name_,
                      backing_store_name,
                      (sizeof this->backing_store_name_ / sizeof (ACE_TCHAR)));

#if !defined (ACE_WIN32)
  if (this->install_signal_handler_)
    {
      if (this->signal_handler_.register_handler (SIGSEGV, this) == -1)
        ACELIB_ERROR ((LM_ERROR,
                    ACE_TEXT("%p\n"), this->backing_store_name_));
    }
#endif /* ACE_WIN32 */
}
开发者ID:Arkania,项目名称:ArkCORE-NG,代码行数:98,代码来源:MMAP_Memory_Pool.cpp



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