[Ace-users] Re: Questions about ACE_Thread and ACE_Thread_Adapter

Dewdman42 dewdman42 at gmail.com
Tue Aug 14 17:19:39 CDT 2007


Thanks so much for the detailed and timely response Doug!  A few
clarifications:

- The code I am working on is going into a library which will not know
if advance if there will or will not be an ACE_Thread_Manager already
in existence, and I don't want to conflict with it if it does already
exist.  My short lived thread only needs to do a few tasks and then
terminate itself.  Also, for this particular task I can't bring in the
ACE_Task overhead, at least for now.  There is a possibility that we
will move to the Pipes and Filter approach later on in the grand
scheme of things, but not now.  I was rather hoping that just using
the lower level ACE_Thread::spawn would be ok, and at least provide me
with platform independence as we build this on several flavors of
UNIX, linux and Win32.

- The example you pointed me to in Thread_Manager.cpp does not show
how and where the Thread_Adapter will be destroyed. ??

- even if I use an auto_ptr for the Thread_Adapter the main problem is
that the dtor is made private, so I guess it can't be destroyed, not
on the stack automatically, not by calling delete manually and not by
having auto-ptr call delete automatically for me.  But maybe I am
missing something.  I see in the Thread_Manager.cpp code that you call
new to create and adapter, and then spawn the thread.  But I don't see
when the thread_args gets destroyed.

- Unfortunately, my $ACE_ROOT tree does not seem to have the book
examples you mentioned (5.5.1).  Not sure why.  I see other examples.
My ACE_ROOT is ACE_Wrappers-5.5.1, which was setup by someone else so
I'm not sure of the exact details.

I have been able to start a thread with ACE_Thread::spawn.  At this
point I can pass it a static C++ method by first creating an instance
of ACE_Thread_Adapter, which wraps around the function.  However, I
don't know how to clean up the adapter when I'm done, and also I was
rather hoping to call a bounded method on an object instance, which
appears to not be possible with my compiler since I can't get the
address of the bounded function to pass to the Thread_Adapter
constructor.  I am trying a work around where I pass a "this" pointer
into a static method and then call a bounded method using that
pointer.  And it sorta seemed to work, but I get core dumps at the
first virtual method call inside the bounded function, so not sure if
this hack is acceptable or not.




More information about the Ace-users mailing list