On Fri, Jan 22, 2010 at 4:25 PM, Mark Miesfeld <[email protected]> wrote:
> I have a few questions on DetachThread.
>
> Does DetachThread() need to be run on the same thread as
> AttachThread()?  Or, if you have the RexxThreadContext pointer, can
> you invoke DetachThread() from a different thread?  I've been assuming
> you could invoke DetachThread() from some other, second thread.

Yes, calling it from another thread would probably work, but I'm not
sure I'd recommend it.

>
> My second question is dependent on the answer to the first question.
> Assuming you can invoke DetachThread() from a second thread, what
> happens if you do a DetachThread() in a second thread after a Rexx
> method has been started on the thread context, but hasn't returned?
>
> Something like:
>
> thread 1 (same thread as thread context was obtained through
> AttachThread.  dlgProcContext is the thread context pointer.)
>
> RexxObjectPtr result = pcpbd->dlgProcContext)->SendMessage(myObj,
> "MYMETHOD", args);
>
> thread 2
>
> if ( pcpbd->dlgProcContext != NULL )
> {
>    pcpbd->dlgProcContext->DetachThread();
>    pcpbd->dlgProcContext = NULL;
> }
>
> In thread 2, it is guaranteed that the SendMessage() is invoked before
> any DetachThread() is done.  But, it is not guaranteed that it has
> returned from myMethod().  Is that going to cause problems?  When, it
> does return, dlgProcContext will not be used again.

That will not work.  DetachThread() can only be called for a thread
context that a) was obtained via AttachThread() and b) there is
nothing active on the thread.  If there is an active method call, then
this cannot be used (which is why I don't really recommend trying to
do a detach from the same thread).

Rick


>
> --
> Mark Miesfeld
>
> ------------------------------------------------------------------------------
> Throughout its 18-year history, RSA Conference consistently attracts the
> world's best and brightest in the field, creating opportunities for Conference
> attendees to learn about information security's most important issues through
> interactions with peers, luminaries and emerging and established companies.
> http://p.sf.net/sfu/rsaconf-dev2dev
> _______________________________________________
> Oorexx-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/oorexx-devel
>

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
Oorexx-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-devel

Reply via email to