Discussion:
[ace-users] Re: Ace_Thread::join for multiple threads
(too old to reply)
Douglas C. Schmidt
2005-05-21 00:15:56 UTC
Permalink
Hi,
When using the Ace_Thread::join() to wait for one or more threads to
exit, how does ACE know how large the array of ace thread id's is?
Is this the function you're discussing:

static int join (ACE_thread_t thread_id,
ACE_thread_t *departed,
ACE_THR_FUNC_RETURN *status);

If so, the documentation was confusing. Here's what it says now:

/// Wait for one or more threads to exit and reap their exit status.
/// thr_join() returns successfully when the target thread terminates.
///
/// If a thr_join() call returns successfully with a non-null
/// status argument, the value passed to thr_exit(3T) by the
/// terminating thread will be placed in the location referenced
/// by status.
///
/// If the target thread ID is 0, thr_join() waits for any
/// undetached thread in the process to terminate on platforms that
/// support this capability (namely Solaris).
///
/// If departed is not 0, it points to a location that is set
/// to the ID of the terminated thread if thr_join() returns
/// successfully.

Take care,

Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Institute for Software Integrated Systems WEB: www.dre.vanderbilt.edu/~schmidt
Vanderbilt University, Nashville TN, 37203 NET: ***@vanderbilt.edu
Alan
2005-05-21 00:35:39 UTC
Permalink
Post by Douglas C. Schmidt
Hi,
When using the Ace_Thread::join() to wait for one or more threads to
exit, how does ACE know how large the array of ace thread id's is?
static int join (ACE_thread_t thread_id,
ACE_thread_t *departed,
ACE_THR_FUNC_RETURN *status);
Douglas:

Thank you for the response. It was the function in question, however
I'm still confused.

I am using Ace_Thread::spawn() to create 3 threads for processing, and
I would like to wait for any one of them to return.

Is this the right approach to take?

If it is, can you point me to a quick example on how to use this
method? If not, what is the right approach to take.

Thank you for your time,
-Alan
Douglas C. Schmidt
2005-05-21 03:20:04 UTC
Permalink
Hi Alan,
Post by Alan
Thank you for the response. It was the function in question, however
I'm still confused.
I am using Ace_Thread::spawn() to create 3 threads for processing, and
I would like to wait for any one of them to return.
Is this the right approach to take?
It depends on the OS platform, e.g., this will work on Solaris, but
not on other platforms. In general, to ensure that we have proper
version/platform/compiler information, please make sure you fill out
the appropriate problem report form (PRF), which is in

$ACE_ROOT/PROBLEM-REPORT-FORM
$TAO_ROOT/PROBLEM-REPORT-FORM

or in

$ACE_ROOT/BUG-REPORT-FORM
$TAO_ROOT/BUG-REPORT-FORM

in older versions of ACE+TAO. Make sure to include this information
when asking any questions about ACE+TAO since otherwise we have to
"guess" what version/platform/compiler/options you've using, which is
error-prone and slows down our responsiveness.
Post by Alan
If it is, can you point me to a quick example on how to use this
method? If not, what is the right approach to take.
There are all sorts of approaches to take. I recommend seeing the
discussion of the ACE_Thread_Manager in Chapter 9 of C++NPv1
<www.cs.wustl.edu/~schmidt/ACE/book1/>.

Thanks,

Doug
--
Dr. Douglas C. Schmidt Professor and Associate Chair
Electrical Engineering and Computer Science TEL: (615) 343-8197
Institute for Software Integrated Systems WEB: www.dre.vanderbilt.edu/~schmidt
Vanderbilt University, Nashville TN, 37203 NET: ***@vanderbilt.edu
Continue reading on narkive:
Loading...