[ace-users] [ace-user] ACE_Thread_Manager::wait
Jeong Ho Lee
friend25kr at gmail.com
Wed Jul 11 21:48:36 CDT 2007
Please help me to improve my understanding on ACE_Thread_Manager.
ACE VERSION: 5.5.4
HOST MACHINE and OPERATING SYSTEM:
Host Machine: Intel Centrio Duo 2GHz meory 1.5GB
OS: Windows Professional SP2
TARGET MACHINE and OPERATING SYSTEM: Same with Host Machine and OS
THE $ACE_ROOT/ace/config.h FILE
#define ACE_HAS_STANDARD_CPP_LIBRARY 1
#define ACE_HAS_MFC 1
DOES THE PROBLEM AFFECT:
ACE_Thread_Manager::wait function behavior
What I understand on the fuction of ACE_Thread_Manager:wait is that
it blocks until there are no more threads running in this thread manager
or timeout expires.
However, it seems not working in my simple program.
I spawn 10 threads in my main function.
Each thread has its own identifier (number) assigned when the
thread is spawned.
With that identifier, the thread prints out its id on the screen.
In the main function, just after finishing spawning all threads, I
call the function
ACE_Thread_Manager::wait with the timeout value of 60 seconds.
What I expect is that my process will not return untile all my
are finish or 60 second-timeout expires. (I assume that 60 seconds are quite
enough time for all the spawned threads finish their assigned job.)
However, my process returnes before that.
Please help me to understand how it happneds.
However it is not working.
My program is listed below.
int main(int argc, char* argv)
for(int i = 0; i < 10; i++)
pthread[i] = new CThread();
ACE_Thread_Manager::instance()->wait(&timeout, false, true);
void* CThread::run_svc(void* arg)
Thread_Args *thread_args = ACE_static_cast(Thread_Args*, arg);
ACE_Thread_Manager *tm = ACE_Thread_Manager::instance();
ACE_thread_t me = ACE_OS::thr_self();
for(int i = 0; i < thread_args->id_; i++)
cout << thread_args->id_ << "(" << i << ")" << " is running" << endl;
void CThread::start(unsigned short id)
Thread_Args *thread_args = new Thread_Args(id, this);
cout << id << " is about to start" << endl;
ACE_static_cast(void*, thread_args), THR_DETACHED | THR_SCOPE_PROCESS)
- Jeong Ho.
More information about the Ace-users