[ace-users] [ace-user] ACE_Thread_Manager::wait
Douglas C. Schmidt
schmidt at dre.vanderbilt.edu
Thu Jul 12 01:31:57 CDT 2007
Thanks for using the PRF.
> ACE VERSION: 5.5.4
Please upgrade to ACE+TAO+CIAO x.5.9 (i.e., ACE 5.5.9, TAO 1.5.9, and
CIAO 0.5.9), which you can download from
under the heading: "Latest Beta Kit".
The DOC groups at Washington University, UC Irvine, and Vanderbilt
University only provide "best effort" support for non-sponsors for the
latest release, as described in
Thus, if you need more "predictable" help for earlier versions of
ACE+TAO, I recommend that you check out
for a list of companies that will provide you with ACE+TAO commercial
> 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
> #define ACE_NO_INLINE
> #include "ace/config-win32.h"
> AREA/CLASS/EXAMPLE AFFECTED:
> 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
> spawned threads
> 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.
Please read the documentation on ACE_Thread_Manager::wait() and you'll
see that it takes *absolute* time, not relative time, so you'll need to
do something like this
ACE_Time_Value timeout (ACE_OS::gettimeofday () + ACE_Time_Value (60));
> However it is not working.
> My program is listed below.
> int main(int argc, char* argv)
> CThread *pthread;
> for(int i = 0; i < 10; i++)
> pthread[i] = new CThread();
> ACE_Time_Value timeout(600);
> ACE_Thread_Manager::instance()->wait(&timeout, false, true);
> return 0;
> 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;
> delete thread_args;
> return 0;
> 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)
> == -1)
> - Jeong Ho.
> ace-users mailing list
> ace-users at mail.cse.wustl.edu
More information about the Ace-users