这篇教程C++ ACE_THR_FUNC函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ACE_THR_FUNC函数的典型用法代码示例。如果您正苦于以下问题:C++ ACE_THR_FUNC函数的具体用法?C++ ACE_THR_FUNC怎么用?C++ ACE_THR_FUNC使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ACE_THR_FUNC函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ACE_TMAINintACE_TMAIN (int, ACE_TCHAR *[]){ // Message list. ACE_Message_Queue<ACE_MT_SYNCH> msg_queue; if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (producer), (void *) &msg_queue, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "spawn"), 1); else if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (consumer), (void *) &msg_queue, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "spawn"), 1); // Wait for producer and consumer threads to exit. ACE_Thread_Manager::instance ()->wait (); return 0;}
开发者ID:esohns,项目名称:ATCD,代码行数:27,
示例2: spawnstatic intspawn (void){ // Create the synchronizer before spawning the child process/thread, // to avoid race condition between the creation in the parent and // use in the child. ACE_NEW_RETURN (synchronizer, SYNCHRONIZER ((unsigned int)0), // Locked by default... -1);#if !defined (ACE_LACKS_FORK) switch (ACE_OS::fork (ACE_TEXT ("child"))) { case -1: ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p/n"), ACE_TEXT ("fork failed")), 1); /* NOTREACHED */ case 0: parent (); // Remove the semaphore. synchronizer->remove (); delete synchronizer; break; /* NOTREACHED */ default: child (); delete synchronizer; break; /* NOTREACHED */ }#elif defined (ACE_HAS_THREADS) if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (child), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p/n"), ACE_TEXT ("thread create failed")), 1); else if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (parent), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P|%t) %p/n"), ACE_TEXT ("thread create failed")), 1); ACE_Thread_Manager::instance ()->wait (); delete synchronizer;#else ACE_UNUSED_ARG (synchronizer); ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("only one thread may be run in a process on this platform/n")), 1);#endif /* ACE_HAS_THREADS */ return 0;}
开发者ID:suiye223,项目名称:ace-linux,代码行数:59,
示例3: run_mainintrun_main (int, ACE_TCHAR *[]){ ACE_START_TEST (ACE_TEXT ("Reactors_Test"));#if defined (ACE_HAS_THREADS) ACE_TEST_ASSERT (ACE_LOG_MSG->op_status () != -1); thr_mgr = ACE_Thread_Manager::instance (); ACE_Reactor reactor; ACE_TEST_ASSERT (ACE_LOG_MSG->op_status () != -1); Test_Task tt1[MAX_TASKS]; Test_Task tt2[MAX_TASKS]; // Activate all of the Tasks. for (int i = 0; i < MAX_TASKS; i++) { tt1[i].open (ACE_Reactor::instance ()); tt2[i].open (&reactor); } // Spawn two threads each running a different reactor. if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (worker), (void *) ACE_Reactor::instance (), THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn")), -1); else if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (worker), (void *) &reactor, THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn")), -1); if (ACE_Thread_Manager::instance ()->wait () == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("wait")), -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) all threads are finished/n")));#else ACE_ERROR ((LM_INFO, ACE_TEXT ("threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0;}
开发者ID:INMarkus,项目名称:ATCD,代码行数:59,
示例4: ACE_TMAINintACE_TMAIN (int argc, ACE_TCHAR *argv[]){ if (argc != 2) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("usage: pingpong <string>/n")), -1); ACE_LOG_MSG->open (argv[0]); string_name = argv[1]; ACE_HANDLE handles[2]; //FUZZ: disable check_for_lack_ACE_OS // Create a pipe and initialize the handles. ACE_Pipe pipe (handles); //FUZZ: enable check_for_lack_ACE_OS#if defined (ACE_WIN32) || defined (CHORUS) if (ACE_Thread::spawn (ACE_THR_FUNC (worker), (void *) handles[0], THR_DETACHED) == -1 || ACE_Thread::spawn (ACE_THR_FUNC (worker), (void *) handles[1], THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n%a"), ACE_TEXT ("spawn"), 1)); barrier.wait ();#else pid_t pid = ACE_OS::fork (argv[0]); if (pid == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n%a"), ACE_TEXT ("fork"), 1)); run_svc (handles[pid == 0]); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) %n: shutting down tester/n")));#endif /* ACE_WIN32 */ if (pipe.close () == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("close"))); return 0;}
开发者ID:azraelly,项目名称:knetwork,代码行数:51,
示例5: ACE_TMAINintACE_TMAIN (int argc, ACE_TCHAR *argv[]){ u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; ACE_TLI_Acceptor server; ACE_TLI_Stream new_stream; // Open the server and reuse the address if in use... if (server.open (ACE_INET_Addr (port), 1) == -1) ACE_OS::t_error ("server.open"), ACE_OS::exit (1); // Wait for a connection from a client. This is an example of a // concurrent server. for (int count = 1; ; count++) { ACE_DEBUG ((LM_DEBUG, "thread %t, blocking for accept #%d/n", count)); if (server.accept (new_stream) == -1) ACE_OS::t_error ("server.accept error"); else if (thr_mgr.spawn (ACE_THR_FUNC (read_file), (void *) new_stream.get_handle (), THR_DETACHED | THR_BOUND) == -1) ACE_OS::perror ("can't create worker thread/n"); } ACE_NOTREACHED (return 0);}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:31,
示例6: run_mainintrun_main (int, ACE_TCHAR *[]){ ACE_START_TEST (ACE_TEXT ("Priority_Buffer_Test"));#if defined (ACE_HAS_THREADS) // Message queue. ACE_Message_Queue<ACE_MT_SYNCH> msg_queue (max_queue); if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (producer), (void *) &msg_queue, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn")), 1); // Wait for producer and consumer threads to exit. ACE_Thread_Manager::instance ()->wait ();#else ACE_ERROR ((LM_INFO, ACE_TEXT ("threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0;}
开发者ID:esohns,项目名称:ATCD,代码行数:27,
示例7: spawnstatic voidspawn (ACE_CLASSIX_Port_Core* theServer){ // create a port for the server ACE_DEBUG ((LM_DEBUG, "(%P|%t) starting server at port %d/n", theServer->get_handle ())); // activate server server_handler handler(TEST_STAMP, *theServer); handler.open(); // make the server active // activate clients // make sure // - we don't let client send messages before the event loop is running ACE_Barrier wait(MAX_TEST_CLIENTS); client_arg data; data.server = theServer; data.wait = &wait; ACE_DEBUG ((LM_DEBUG, "(%t) starting clients/n")); if (ACE_Thread_Manager::instance ()->spawn_n (MAX_TEST_CLIENTS, ACE_THR_FUNC (client), (void *) &data, THR_BOUND | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, "(%P|%t) %p/n%a", "spawn failed")); // handle event ACE_DEBUG((LM_DEBUG, "(%t)run event loop/n")); ACE_Reactor::run_event_loop(); // wait until all server has completed ACE_Thread_Manager::instance()->wait_task(&handler);}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:34,
示例8: ACE_TMAINintACE_TMAIN (int argc, ACE_TCHAR *argv[]){ // The Service_Config must be the first object defined in main... ACE_Service_Config daemon (argv[0]); int threads = argc > 1 ? ACE_OS::atoi (argv[1]) : 4; intptr_t count = argc > 2 ? ACE_OS::atoi (argv[2]) : 10000; // Register a signal handler. ACE_Sig_Action sa ((ACE_SignalHandler) (handler), SIGINT); ACE_UNUSED_ARG (sa);#if defined (ACE_HAS_THREADS) if (ACE_Thread_Manager::instance ()->spawn_n (threads, ACE_THR_FUNC (&worker), reinterpret_cast<void *> (count), THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "ACE_Thread_Manager::spawn_n"), -1); ACE_Thread_Manager::instance ()->wait ();#else worker ((void *) count);#endif /* ACE_HAS_THREADS */ return 0;}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:29,
示例9: peer2static void *peer2 (void *){ ACE_UPIPE_Acceptor acc (addr); ACE_UPIPE_Stream s_stream; // Spawn a peer1 thread. if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (peer1), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "spawn"), 0); ACE_DEBUG ((LM_DEBUG, "(%t) peer2 starting accept/n")); if (acc.accept (s_stream) == -1) ACE_ERROR ((LM_ERROR, "(%t) ACE_UPIPE_Acceptor.accept failed/n")); ACE_Message_Block *mb = 0; if (s_stream.recv (mb) == -1) ACE_ERROR ((LM_ERROR, "(%t) peer2 recv failed/n")); ACE_DEBUG ((LM_DEBUG, "(%t) peer2 recv is /"%s/"/n", mb->rd_ptr ())); mb->wr_ptr (mb->rd_ptr ()); mb->copy ("thanks", 7); if (s_stream.send (mb) == -1) ACE_ERROR ((LM_ERROR, "(%t) peer2 send failed/n")); char s_buf[42]; ACE_DEBUG ((LM_DEBUG, "(%t) peer2 sleeping on recv/n")); if (s_stream.recv (s_buf, sizeof s_buf) == -1) ACE_ERROR ((LM_ERROR, "(%t) peer2 recv failed/n")); else ACE_DEBUG ((LM_DEBUG, "(%t) peer2 received buffer with /"%s/"/n", s_buf)); ACE_OS::strcpy (s_buf, "this is the peer2 response!"); if (s_stream.send (s_buf, 30) == -1) ACE_ERROR ((LM_ERROR, "(%t) peer2 send failed/n")); s_stream.close (); return 0;}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:59,
示例10: run_mainintrun_main (int argc, ACE_TCHAR *argv[]){ ACE_START_TEST (ACE_TEXT ("Reactor_Exceptions_Test")); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Starting tracing/n"))); u_short port = argc > 1 ? ACE_OS::atoi (argv[1]) : ACE_DEFAULT_SERVER_PORT; ACE_INET_Addr local_addr (port); ACE_INET_Addr remote_addr (port, ACE_LOCALHOST, PF_INET); ACE_Reactor reactor (new My_Reactor, true); ACE_Reactor::instance (&reactor); ACE_Thread_Manager *thr_mgr = ACE_Thread_Manager::instance (); { // Make sure handler gets cleaned up before reactor by putting it in its // own scope My_Handler handler (local_addr); if (ACE_Reactor::instance ()->register_handler (&handler, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("register_handler")), -1);#if defined (ACE_HAS_THREADS) thr_mgr->spawn (ACE_THR_FUNC (worker));#else // Need to figure out how to implement this test. ACE_ERROR ((LM_INFO, ACE_TEXT ("threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_SOCK_Dgram dgram (ACE_sap_any_cast (ACE_INET_Addr &), PF_INET); for (size_t i = 0; i < ACE_MAX_ITERATIONS; i++) dgram.send (ACE_TEXT ("Hello"), sizeof (ACE_TEXT ("Hello")), remote_addr); // Barrier to wait for the other thread to return. thr_mgr->wait (); handler.close (); dgram.close (); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) exiting main/n"))); ACE_END_TEST; return 0;}
开发者ID:esohns,项目名称:ATCD,代码行数:58,
示例11: Transcodevoid Transcode(CStdString &file){ OrkLogManager::Instance()->Initialize(); ObjectFactory::GetSingleton()->Initialize(); ConfigManager::Instance()->Initialize(); std::list<ACE_DLL> pluginDlls; LoadPlugins(pluginDlls); // Register in-built filters FilterRef filter(new AlawToPcmFilter()); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new UlawToPcmFilter()); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new GsmToPcmFilter()); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new IlbcToPcmFilter()); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new AudioGainFilter()); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new G722ToPcmFilter()); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new SpeexDecoder() ); FilterRegistry::instance()->RegisterFilter(filter); filter.reset(new G721CodecDecoder()); FilterRegistry::instance()->RegisterFilter(filter); // Register in-built tape processors and build the processing chain BatchProcessing::Initialize(); Reporting::Initialize(); TapeFileNaming::Initialize(); if (!ACE_Thread_Manager::instance()->spawn(ACE_THR_FUNC(BatchProcessing::ThreadHandler))) { LOG4CXX_INFO(LOG.rootLog, CStdString("Failed to create batch processing thread")); } // Transmit the tape to the BatchProcessing CStdString ProcessorName("BatchProcessing"); TapeProcessorRef bp = TapeProcessorRegistry::instance()->GetNewTapeProcessor(ProcessorName); CStdString portName("SinglePort"); AudioTapeRef tape(new AudioTape(portName, file)); bp->AddAudioTape(tape); // Make sure it stops after processing tape.reset(); bp->AddAudioTape(tape); // Wait for completion while(!Daemon::Singleton()->IsStopping()) { ACE_OS::sleep(1); }}
开发者ID:HiPiH,项目名称:Oreka,代码行数:58,
示例12: run_mainintrun_main (int, ACE_TCHAR *[]){ ACE_START_TEST (ACE_TEXT ("TSS_Test"));#if defined (ACE_HAS_THREADS) Errno::allocate_lock (); const u_int threads = ACE_MAX_THREADS; // Dynamically allocate TSS_Error so that we can control when it // gets deleted. Specifically, we need to delete it before the // ACE_Object_Manager destroys the ACE_Allocator. That's because // deletion of TSS_Error causes the internal structures of // ACE_TSS_Cleanup to be modified, and which in turn uses // ACE_Allocator. ACE_NEW_RETURN (tss_error, ACE_TSS<Errno>, 1); // Similarly, dynamically allocate u. ACE_NEW_RETURN (u, ACE_TSS<ACE_TSS_Type_Adapter<u_int> >, 1); int iterations = ITERATIONS; if (ACE_Thread_Manager::instance ()->spawn_n (threads, ACE_THR_FUNC (worker), &iterations, THR_BOUND) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn_n")), 1); ACE_Thread_Manager::instance ()->wait (); delete u; delete tss_error; Errno::deallocate_lock (); if (Errno::created () != Errno::deleted ()) { //@@TODO: this should probably be promoted to an error rather than just a // warning. ACE_ERROR ((LM_DEBUG, ACE_TEXT ("(%P|%t) Warning: Number created (%d) != number deleted (%d)/n"), Errno::created (), Errno::deleted () )); }#else /* ACE_HAS_THREADS */ ACE_ERROR ((LM_INFO, ACE_TEXT ("threads are not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return errors ? -1 : 0;}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:57,
示例13: run_mainint run_main (int argc, ACE_TCHAR *argv[]){ ACE_START_TEST (ACE_TEXT ("Manual_Event_Test"));#if defined (ACE_HAS_THREADS) parse_args (argc, argv); if (ACE_Thread_Manager::instance ()->spawn_n (static_cast<size_t> (n_workers), ACE_THR_FUNC (worker), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn_n")), 1); // gives all workers chance to start ACE_OS::sleep (5); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("sending pulse ()/n"))); // Release the all workers. if (evt.pulse () == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("pulse")), 1); // Wait 2 sec ACE_OS::sleep (2); //FUZZ: disable check_for_lack_ACE_OS ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("sending signal ()/n"))); //FUZZ: enable check_for_lack_ACE_OS // Signal if (evt.signal () == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("signal")), 1); ACE_Thread_Manager::instance ()->wait ();#else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("Threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return test_result;}
开发者ID:helixum,项目名称:wow-cata,代码行数:55,
示例14: run_mainintrun_main (int, ACE_TCHAR *[]){ ACE_START_TEST (ACE_TEXT ("UPIPE_SAP_Test"));#if defined (ACE_HAS_THREADS) && / (defined (ACE_HAS_STREAM_PIPES) || defined (ACE_HAS_WIN32_NAMED_PIPES)) ACE_UPIPE_Acceptor acc (addr); // Spawn a acceptor thread. if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (acceptor), (void *) &acc, THR_NEW_LWP, 0) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn")), 1); // Spawn a connector thread. if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (connector), (void *) 0, THR_NEW_LWP, 0) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn")), 1); ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) joined with acceptor thread/n"))); // Close the acceptor acc.close ();#else#if !defined (ACE_HAS_THREADS) ACE_ERROR ((LM_INFO, ACE_TEXT ("threads not supported on this platform/n")));#else ACE_ERROR ((LM_INFO, ACE_TEXT ("UPIPE is not supported on this platform/n")));#endif /* !defined (ACE_HAS_THREADS) */#endif /* ACE_HAS_THREADS && (ACE_HAS_STREAM_PIPES || ACE_HAS_WIN32_NAMED_PIPES) */ ACE_END_TEST; return 0;}
开发者ID:asdlei00,项目名称:ACE,代码行数:42,
示例15: run_mainint run_main (int argc, ACE_TCHAR *argv[]){ ACE_START_TEST (ACE_TEXT ("Reader_Writer_Test"));#if defined (ACE_HAS_THREADS) parse_args (argc, argv); current_readers = 0; // Possibly already done current_writers = 0; // Possibly already done ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) main thread starting/n"))); if (ACE_Thread_Manager::instance ()->spawn_n (n_readers, ACE_THR_FUNC (reader), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn_n")), 1); else if (ACE_Thread_Manager::instance ()->spawn_n (n_writers, ACE_THR_FUNC (writer), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn_n")), 1); ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT (" (%t) exiting main thread/n")));#else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0;}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:41,
示例16: voidCORBAShutdown::shutdown(){ if (!m_func) return; ACE_OS::sleep(1); ACE_Thread_Manager *thr_mgr = ACE_Thread_Manager::instance (); thr_mgr->spawn (ACE_THR_FUNC (worker), (void*)m_func);}
开发者ID:ACS-Community,项目名称:ACS,代码行数:12,
示例17: GetLogLevel//初始化日志策略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;}
开发者ID:0328shijian,项目名称:PSS,代码行数:54,
示例18: ACE_TMAINintACE_TMAIN (int argc, ACE_TCHAR *argv[]){ ACE_Service_Config daemon; daemon.open (argv[0]); // Register a signal handler. ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT); ACE_UNUSED_ARG (sa); int n_threads = argc > 1 ? ACE_OS::atoi (argv[1]) : DEFAULT_THREADS; intptr_t n_iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : DEFAULT_ITERATIONS; ACE_Thread_Manager *thr_mgr = ACE_Thread_Manager::instance (); int grp_id = thr_mgr->spawn_n (n_threads, ACE_THR_FUNC (worker), reinterpret_cast<void *> (n_iterations), THR_NEW_LWP | THR_DETACHED); // Wait for 1 second and then suspend every thread in the group. ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, "(%t) suspending group/n")); if (thr_mgr->suspend_grp (grp_id) == -1) ACE_ERROR ((LM_DEBUG, "(%t) %p/n", "suspend_grp")); // Wait for 1 more second and then resume every thread in the // group. ACE_OS::sleep (ACE_Time_Value (1)); ACE_DEBUG ((LM_DEBUG, "(%t) resuming group/n")); if (thr_mgr->resume_grp (grp_id) == -1) ACE_ERROR ((LM_DEBUG, "(%t) %p/n", "resume_grp")); // Wait for 1 more second and then send a SIGINT to every thread in // the group. ACE_OS::sleep (ACE_Time_Value (1)); ACE_DEBUG ((LM_DEBUG, "(%t) signaling group/n")); if (thr_mgr->kill_grp (grp_id, SIGINT) == -1) ACE_ERROR ((LM_DEBUG, "(%t) %p/n", "kill_grp")); // Wait for 1 more second and then cancel all the threads. ACE_OS::sleep (ACE_Time_Value (1)); ACE_DEBUG ((LM_DEBUG, "(%t) cancelling group/n")); if (thr_mgr->cancel_grp (grp_id) == -1) ACE_ERROR ((LM_DEBUG, "(%t) %p/n", "cancel_grp")); // Perform a barrier wait until all the threads have shut down. thr_mgr->wait (); return 0;}
开发者ID:esohns,项目名称:ATCD,代码行数:52,
示例19: run_mainintrun_main (int argc, ACE_TCHAR *argv[]){ ACE_START_TEST (ACE_TEXT ("Recursive_Mutex_Test"));#if defined (ACE_HAS_THREADS) if (argc > 1) { n_threads = ACE_OS::atoi (argv[1]); } ACE_TEST_MUTEX rm;#if !defined (ACE_HAS_WTHREADS) // This will work for Windows, too, if ACE_TEST_MUTEX is // ACE_Recursive_Thread_Mutex instead of ACE_Process_Mutex. nesting_level_supported = (rm.get_nesting_level () != -1 || errno != ENOTSUP);#endif /* !ACE_HAS_WTHREADS */ ACE_Thread_Manager::instance ()->spawn_n (n_threads, ACE_THR_FUNC (recursion_worker), (void *) &rm); ACE_Thread_Manager::instance ()->wait (); ACE_Thread_Manager::instance ()->spawn_n (n_threads, ACE_THR_FUNC (timed_worker), (void *) &rm); ACE_Thread_Manager::instance ()->wait ();#else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE doesn't support recursive process ") ACE_TEXT ("mutexes on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return 0;}
开发者ID:CCJY,项目名称:ACE,代码行数:39,
示例20: ACE_TMAINintACE_TMAIN (int, ACE_TCHAR *[]){ // Message queue. ACE_Message_Queue<ACE_MT_SYNCH> msg_queue (max_queue); if (thr_mgr.spawn (ACE_THR_FUNC (producer), (void *) &msg_queue, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "spawn"), 1); // Wait for producer and consumer threads to exit. thr_mgr.wait (); return 0;}
开发者ID:CCJY,项目名称:ACE,代码行数:14,
示例21: run_mainintrun_main (int, ACE_TCHAR *[]){ ACE_START_TEST (ACE_TEXT ("SPIPE_Test"));#if defined (TEST_HAS_STREAM_PIPES)#if !defined (ACE_LACKS_FORK) switch (ACE_OS::fork ()) { case -1: ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n%a"), ACE_TEXT ("fork failed"))); ACE_OS::exit (-1); case 0: client (0); default: server (0); }#elif defined (ACE_HAS_THREADS) if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (client), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n%a"), ACE_TEXT ("thread create failed"))); if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (server), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p/n%a"), ACE_TEXT ("thread create failed"))); ACE_Thread_Manager::instance ()->wait ();#endif /* !ACE_LACKS_EXEC */#else ACE_DEBUG ((LM_INFO, ACE_TEXT ("SPIPE is not supported on this platform/n")));#endif /* TEST_HAS_STREAM_PIPES */ ACE_END_TEST; return 0;}
开发者ID:CCJY,项目名称:ACE,代码行数:37,
示例22: ACE_TMAINintACE_TMAIN (int, ACE_TCHAR *[]){ // Spawn a peer2 thread. if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (peer2), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "spawn"), 1); // Wait for peer2 and peer1 threads to exit. ACE_Thread_Manager::instance ()->wait (); return 0;}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:15,
示例23: ACE_TMAINintACE_TMAIN (int argc, ACE_TCHAR *argv[]){ ACE_Service_Config daemon (argv[0]); parse_args (argc, argv); ACE_Recursive_Thread_Mutex rm; ACE_Thread_Manager::instance ()->spawn_n (n_threads, ACE_THR_FUNC (worker), (void *) &rm); ACE_Thread_Manager::instance ()->wait (); return 0;}
开发者ID:DOCGroup,项目名称:ACE_TAO,代码行数:15,
示例24: run_mainint run_main (int argc, ACE_TCHAR *argv[]){ ACE_START_TEST (ACE_TEXT ("Semaphore_Test"));#if defined (ACE_HAS_THREADS) parse_args (argc, argv); ACE_OS::srand (ACE_OS::time (0L));# if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM) //Test timed waits. for (size_t i = 0; i < test_timeout_count; i++) if (test_timeout () != 0) test_result = 1;# endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */ // Release the semaphore a certain number of times. s.release (n_release_count); if (ACE_Thread_Manager::instance ()->spawn_n (ACE_static_cast (size_t, n_workers), ACE_THR_FUNC (worker), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn_n")), 1); ACE_Thread_Manager::instance ()->wait ();# if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM) size_t percent = (timeouts * 100) / (n_workers * n_iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Worker threads timed out %d percent of the time/n"), percent));# endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Semaphore Test successful/n")));#else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("Threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return test_result;}
开发者ID:BackupTheBerlios,项目名称:pyasynchio-svn,代码行数:48,
示例25: ACE_DEBUGvoidHello::method (CORBA::Short count){ if (++this->count_ > 10) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) supplied count = %d/n", count)); PortableServer::POA_var poa = this->_default_POA(); PortableServer::POAManager_var mgr = poa->the_POAManager(); mgr->hold_requests(false); // Pass duplicated ptr to a thread and let the thread to free the reference. CORBA::ORB_ptr orb = CORBA::ORB::_duplicate (this->orb_.in ()); ACE_Thread_Manager::instance()->spawn_n (1, ACE_THR_FUNC (killer), static_cast<void*> (orb)); }}
开发者ID:asdlei00,项目名称:ACE,代码行数:16,
示例26: run_mainint run_main (int argc, ACE_TCHAR *argv[]){ ACE_START_TEST (ACE_TEXT ("Auto_Event_Test"));#if defined (ACE_HAS_THREADS) parse_args (argc, argv); ACE_OS::srand ((u_int) ACE_OS::time (0L)); //Test timed waits. for (size_t i = 0; i < test_timeout_count; i++) if (test_timeout () != 0) test_result = 1; if (ACE_Thread_Manager::instance ()->spawn_n (static_cast<size_t> (n_workers), ACE_THR_FUNC (worker), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p/n"), ACE_TEXT ("spawn_n")), 1); // Release the first worker. evt.signal (); ACE_Thread_Manager::instance ()->wait (); size_t percent = (timeouts * 100) / (n_workers * n_iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Worker threads timed out %d percent of the time/n"), (int)percent)); if (test_result == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Auto_Event Test successful/n")));#else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("Threads not supported on this platform/n")));#endif /* ACE_HAS_THREADS */ ACE_END_TEST; return test_result;}
开发者ID:chrrrisw,项目名称:ACE,代码行数:45,
示例27: ACE_TMAINintACE_TMAIN (int argc, ACE_TCHAR *argv[]){ size = argc > 1 ? ACE_OS::atoi (argv[1]) : 32; iterations = argc > 2 ? ACE_OS::atoi (argv[2]) : 16; // Spawn the two threads. if (ACE_Thread_Manager::instance ()->spawn (ACE_THR_FUNC (consumer), (void *) 0, THR_NEW_LWP | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p/n", "spawn"), 1); // Wait for producer and consumer threads to exit. ACE_Thread_Manager::instance ()->wait (); return 0;}
开发者ID:binghuo365,项目名称:BaseLab,代码行数:18,
注:本文中的ACE_THR_FUNC函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ACE_TRACE函数代码示例 C++ ACE_TEXT_ALWAYS_CHAR函数代码示例 |