oneway void causing deadlock
oneway void causing deadlock
- Subject: oneway void causing deadlock
- From: Aram Greenman <email@hidden>
- Date: Mon, 17 Jun 2002 21:26:52 -0700
Here is the problem:
Several workers each run in their own thread, each connected to the boss
by an NSConnection. The main function of the workers is to listen for
data from the network and forward it to the boss with -[Boss
received
Data:fromWorker:]
- (void)receivedData:(bycopy Data *)d fromWorker:(byref Worker *)w;
currently this method is a no-op.
A worker continues to loop on this method until the boss sets an abort
flag, or an exception is raised, which causes the worker to set its own
abort flag.
while (!abort) {
NS_DURING {
[boss received
Data:[self getData] fromWorker:self];
} NS_HANDLER {
[self abort]; // sets abort = YES
} NS_ENDHANDLER;
}
OK, this works, but I don't want my worker threads wasting time waiting
for the boss to process the data so I changed the return value of -[Boss
received
Data:fromWorker:] from 'void' to 'oneway void'.
Now the first time an exception is raised in any worker thread I get
deadlock. The top of every thread's stack frame is a
mach_msg_overwrite_trap. The thread which raised the exception is stuck
in -[NSThread _exit].
I must be missing something, right? If this post is not detailed enough
let me know, I tried to strip it down to the simplest possible example.
aram
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.