int main (int argc, char *argv[]) { ACE_LOG_MSG->open (argv[0]); parse_args (argc, argv); current_readers = 0; // Possibly already done current_writers = 0; // Possibly already done ACE_DEBUG ((LM_DEBUG, "(%t) main thread starting\n")); if (thr_mgr.spawn_n (n_readers, (ACE_THR_FUNC) reader, 0, THR_NEW_LWP) == -1 || thr_mgr.spawn_n (n_writers, (ACE_THR_FUNC) writer, 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); thr_mgr.wait (); ACE_DEBUG ((LM_DEBUG, "(%t) exiting main thread\n")); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { if (parse_args (argc, argv) == -1) return -1; if (remote) { ACE_Remote_Mutex::set_server_address (ACE_INET_Addr (server_port, server_host)); global_rlock = (ACE_Token_Proxy *) new ACE_Remote_RLock ("THE_TOKEN", ignore_deadlock, debug); global_wlock = (ACE_Token_Proxy *) new ACE_Remote_WLock ("THE_TOKEN", ignore_deadlock, debug); } else { global_rlock = (ACE_Token_Proxy *) new ACE_Local_RLock ("THE_TOKEN", ignore_deadlock, debug); global_wlock = (ACE_Token_Proxy *) new ACE_Local_WLock ("THE_TOKEN", ignore_deadlock, debug); } ACE_Thread_Manager mgr; if (mgr.spawn_n (threads, ACE_THR_FUNC (run_thread), (void *) 0, THR_BOUND | SUSPEND) == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "spawn failed"), -1); #if ! defined (ACE_HAS_PTHREADS) if (mgr.resume_all () == -1) ACE_ERROR_RETURN ((LM_DEBUG, "%p\n", "resume failed"), -1); #endif mgr.wait (); return 0; }