YADOTQ (Yet Another DO Threading Question)
YADOTQ (Yet Another DO Threading Question)
- Subject: YADOTQ (Yet Another DO Threading Question)
- From: Mike Shields <email@hidden>
- Date: Tue, 10 Jul 2001 02:46:50 -0600
I'm a little unsure of some things dealing with thread completion and DO.
I've set up a worker thread with a connection to the main thread through
DO. This thread periodically reports back progress to the main thread.
When it's all done I want it to tell the main thread it's done. The main
thread will then tear down the connection and destroy the progress
window and some other objects. I'm worried about tearing down the
connection between the main thread and the worker thread. If I do the
tear down in the -(void)workerDone method running in the main thread,
will this cause a race condition and cause problems in the worker thread
with the method running in the worker thread unwinding on a stack that's
been torn down when NSThread exit is called??
Should I possibly set up an NSTimer to do the cleanup?? Should/can I
have the worker thread kill it's own runloop and cleanup itself? Is all
this timing/race condition not a problem because the runloop ends up
syncronizing these things?
Maybe a diagram might help:
Main Thread Worker Thread
- startWork
(makes connection and starts worker) - connectWithPorts gunk
[server doWork]
- doWork
[proxy updateProgress]
- updateProgress updates window, etc
do work
etc.
done, call [proxy workerDone]
- workerDone tears down connection and
tells it's owner we're all done
(in here I'm worried about
running on
a stale thread stack before
the work
method completes)
controller owner tears down controller