Re: Problem cancelling lengthy task in secondary thread
Re: Problem cancelling lengthy task in secondary thread
- Subject: Re: Problem cancelling lengthy task in secondary thread
- From: Jörn Salewski <email@hidden>
- Date: Thu, 30 Oct 2003 18:12:46 +0100
>
I think I may just have spotted the problem.
Admittedly, without fully understanding your answer, yes, I think you did.
>
I had assumed that you
>
were just setting _continue from the main thread, but you aren't...
>
you're using DO to call your object, right?
Yes, indeed I do.
>
Well, I think you'll find
>
that DO relies on the run-loop. Presumably _TOCAuthor and/or _TOCWork
>
are passed-in via DO from your main thread? If they are, then invoking
>
methods on them will cause event processing to occur whilst the DO
>
proxy object waits for a reply... and because events are being
>
processed, the call to -setContinueSearch: can be triggered at that
>
point. -setContinueSearch can't be triggered during the inner loops,
>
because there is no event processing going on.
>
>
To see what I mean, add some NSLog() calls, one in -setContinueSearch,
>
one just after the "if (! _continue) break;" statement, and one before
>
"int error = 0". I think you'll find that -setContinueSearch is
>
*always* executed between those two lines, and never in any other place.
>
>
You'll probably also find that calling *any* (non-oneway) method on an
>
object provided by the main thread within your inner loops will make
>
your program work.
>
Somehow, I feel quite helpless with DO and multithreading in general. I'm
very unfamiliar with this topic and don't know much about the implications
different implementations might have (like the one you described).
Befor reading your reply, I did a little test sacrificing DO and creating
consecutively different threads for the search method from the controlling
object. This way the "if (! _continue)" check works as I expected it to do
in the first place. But I don't know if it's better to work with DO and to
cross the DO-bridge all the time after each match or to create say a 100
threads after each other for every author.
Mmmh, probably I have to figure that out myself by testing...
Anyway, thanks very much for your reply.
Cheers,
JS
>
Kind regards,
>
>
Alastair.
>
_______________________________________________
>
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.
_______________________________________________
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.