static void
create_reactor (void)
{
  ACE_Reactor_Impl *impl = 0;

  if (opt_wfmo_reactor)
    {
#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 == 1)
      ACE_NEW (impl, ACE_WFMO_Reactor);
#endif /* ACE_HAS_WINSOCK2 == 1 */
    }
  else if (opt_select_reactor)
    {
      ACE_NEW (impl, ACE_Select_Reactor);
    }
  else if (opt_dev_poll_reactor)
    {
#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
      ACE_NEW (impl, ACE_Dev_Poll_Reactor);
#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */
    }
  ACE_Reactor *reactor = 0;
  ACE_NEW (reactor, ACE_Reactor (impl));
  ACE_Reactor::instance (reactor);
}
int
MyTask::create_reactor (void)
{
  ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX,
                    monitor,
                    this->lock_,
                    -1);

  ACE_ASSERT (this->my_reactor_ == 0);

  ACE_TP_Reactor * pImpl = 0;

  ACE_NEW_RETURN (pImpl,ACE_TP_Reactor, -1);

  ACE_NEW_RETURN (my_reactor_,
                   ACE_Reactor (pImpl ,1),
                   -1);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT (" (%t) Create TP_Reactor\n")));

  ACE_Reactor::instance (this->my_reactor_);

  this->reactor (my_reactor_);

  return 0;
}
Exemple #3
0
//
// Selection of which reactor should get created
//
ACE_Reactor *
create_reactor (void)
{
  ACE_Reactor_Impl *impl = 0;

  if (opt_wfmo_reactor)
    {
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
      ACE_NEW_RETURN (impl,
                      ACE_WFMO_Reactor,
                      0);
#endif /* ACE_WIN32 */
    }
  else if (opt_select_reactor)
    {
      ACE_NEW_RETURN (impl,
                      ACE_Select_Reactor,
                      0);
    }
  else
    {
      ACE_Reactor *singleton_reactor =
        ACE_Reactor::instance ();
      ACE_Reactor::instance (0);
      return singleton_reactor;
    }

  ACE_Reactor *reactor = 0;
  ACE_NEW_RETURN (reactor,
                  ACE_Reactor (impl,
                               1),
                  0);

  return reactor;
}
//初始化日志策略
int Frame_Logging_Strategy::InitLogStrategy(Logging_Config_Param &ConfigParam)
{
    //Set Arg List
    char cmdline[1024] = {0};

    string strTemp = ConfigParam.m_strLogLevel;
    string strLogLevel = GetLogLevel(strTemp);

    if(ConfigParam.m_bSendTerminal)
    {
        ACE_OS::sprintf(cmdline,"-s %s -f STDERR -p %s -i %d -m %d -N %d",
                        ConfigParam.m_strLogFile,
                        strLogLevel.c_str(),
                        ConfigParam.m_iChkInterval,
                        ConfigParam.m_iLogFileMaxSize,
                        ConfigParam.m_iLogFileMaxCnt);
    }
    else
    {
        ACE_OS::sprintf(cmdline,"-s %s -f OSTREAM -p %s -i %d -m %d -N %d",
                        ConfigParam.m_strLogFile,
                        strLogLevel.c_str(),
                        ConfigParam.m_iChkInterval,
                        ConfigParam.m_iLogFileMaxSize,
                        ConfigParam.m_iLogFileMaxCnt);
    }

    ACE_Reactor_Impl * pImpl = 0;

    ACE_NEW_RETURN (pImpl, ACE_TP_Reactor, -1);
    

    ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor(pImpl ,1), -1);
    //ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor, -1);
    ACE_NEW_RETURN(pLogStrategy, My_ACE_Logging_Strategy, -1);

    //Set Reactor
    pLogStrategy->reactor(pLogStraReactor);

    ACE_ARGV args;
    //args.add(__argv[0]);
    args.add(ACE_TEXT(cmdline));

    pLogStrategy->init(args.argc(),args.argv());

    if (ACE_Thread_Manager::instance ()->spawn(ACE_THR_FUNC (run_reactor), (void *)pLogStraReactor) == -1)
    {
        ACE_ERROR_RETURN ((LM_ERROR,"Spawning Reactor.\n"),-1);
    }

    ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) %M Init Log Strategy Success [%N,%l]\n")));
    return 0;
}
//
// Software_Probe_Task
//
Software_Probe_Task::
Software_Probe_Task (Software_Probe_Impl * probe)
: probe_ (probe),
  is_active_ (false),
  timer_id_ (-1)
{
  ACE_Reactor * reactor = 0;

  ACE_NEW_THROW_EX (reactor,
                    ACE_Reactor (),
                    ACE_bad_alloc ());

  this->reactor (reactor);
}
static void
create_reactor (void)
{
    ACE_Reactor_Impl *impl = 0;

    if (opt_wfmo_reactor)
    {
#if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
        ACE_NEW (impl, ACE_WFMO_Reactor);
#endif /* ACE_WIN32 */
    }
    else if (opt_select_reactor)
    {
        ACE_NEW (impl, ACE_Select_Reactor);
    }
    ACE_Reactor *reactor = 0;
    ACE_NEW (reactor, ACE_Reactor (impl));
    ACE_Reactor::instance (reactor);
}
Exemple #7
0
static void
create_reactor (void)
{
  ACE_Reactor_Impl *impl = 0;

#if defined (TEST_CAN_USE_WFMO_REACTOR)
  if (opt_wfmo_reactor)
    ACE_NEW (impl,
             ACE_WFMO_Reactor);
#endif /* TEST_CAN_USE_WFMO_REACTOR */

  if (impl == 0 && opt_select_reactor)
    ACE_NEW (impl,
             ACE_Select_Reactor);

  ACE_Reactor *reactor = 0;
  ACE_NEW (reactor,
           ACE_Reactor (impl));
  ACE_Reactor::instance (reactor);
}
int
TP_ReactorTask::create_demultiplexor(void)
{
  ACE_ASSERT (this->tp_reactor_ == 0);

  ACE_TP_Reactor * pImpl = 0;

  ACE_NEW_RETURN (pImpl,ACE_TP_Reactor, -1);

  ACE_NEW_RETURN (tp_reactor_,
                   ACE_Reactor (pImpl ,1),
                   -1);

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Create TP_Reactor\n")));

  // ACE_Reactor::instance (this->my_reactor_);

  this->reactor (tp_reactor_);

  return 0;
}
Exemple #9
0
static int
run_test (int disable_notify_pipe,
          const ACE_Time_Value &tv)
{
  // Create special reactors with the appropriate flags enabled.

  ACE_Select_Reactor *reactor_impl = 0;
  if (disable_notify_pipe)
    ACE_NEW_RETURN (reactor_impl,
                    ACE_Select_Reactor (0, 0, 1),
                    -1);
  else
    ACE_NEW_RETURN (reactor_impl,
                    ACE_Select_Reactor,
                    -1);

  ACE_Reactor *reactor;
  ACE_NEW_RETURN (reactor,
                  ACE_Reactor (reactor_impl, 1),    // Delete implementation
                  -1);

  // Make sure this stuff gets cleaned up when this function exits.
  auto_ptr<ACE_Reactor> r (reactor);

  // Set the Singleton Reactor.
  ACE_Reactor *orig_reactor = ACE_Reactor::instance (reactor);
  ACE_TEST_ASSERT (ACE_LOG_MSG->op_status () != -1);
  ACE_TEST_ASSERT (ACE_Reactor::instance () == reactor);

  Supplier_Task task (disable_notify_pipe,
                      tv);
  ACE_TEST_ASSERT (ACE_LOG_MSG->op_status () != -1);

  int result;

  result = task.open ();
  ACE_TEST_ASSERT (result != -1);

  if (tv.sec () == LONG_TIMEOUT)
    // Sleep for a while so that the <ACE_Reactor>'s notification
    // buffers will fill up!
    ACE_OS::sleep (tv);

  int shutdown = 0;

  // Run the event loop that handles the <handle_output> and
  // <handle_exception> notifications.
  for (int iteration = 1;
       shutdown == 0;
       iteration++)
    {
      ACE_Time_Value timeout (tv);

      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("(%t) starting handle_events() on iteration %d")
                  ACE_TEXT (" with time-out = %d seconds\n"),
                  iteration,
                  timeout.sec ()));

      // Use a timeout to inform the Reactor when to shutdown.
      switch (ACE_Reactor::instance ()->handle_events (timeout))
        {
        case -1:
          if (! disable_notify_pipe)
            ACE_ERROR ((LM_ERROR,
                        ACE_TEXT ("(%t) %p\n"),
                        ACE_TEXT ("reactor")));
          shutdown = 1;
          break;
          /* NOTREACHED */
        case 0:
          ACE_DEBUG ((LM_DEBUG,
                      ACE_TEXT ("(%t) handle_events timed out\n")));
          shutdown = 1;
          break;
          /* NOTREACHED */
        default:
          break;
          /* NOTREACHED */
        }
    }

  if (tv.sec () == LONG_TIMEOUT)
    {
      ACE_DEBUG ((LM_DEBUG,
                  ACE_TEXT ("(%t) releasing supplier task thread\n")));
      task.release ();
    }
  ACE_Reactor::instance (orig_reactor);
  return 0;
}