On 14 Jul 2008, at 8:57 PM, Adam Maxwell wrote:
> On 2008-07-14 11:21:21 -0700, Christiaan Hofman <[EMAIL PROTECTED]>
> said:
>
>>
>> On 14 Jul 2008, at 7:49 PM, Adam Maxwell wrote:
>>
>>> On 2008-07-14 10:10:15 -0700, Christiaan Hofman <[EMAIL PROTECTED]>
>>> said:
>>>> The main reason it's set in the main thread is that a running
>>>> (long)
>>>> task may decide to stop executing, e.g. in a long while-loop. If
>>>> shouldKeepRunning is set to 0 on the server thread it won't happen
>>>> till the current calculation has finished.
>>>
>>> It won't happen until the end of the calculation loop anyway unless
>>> the
>>> calculation loop runs the runloop and checks that flag, though,
>>> right?
>>>
>>
>> It may. The shouldKeepRunning flag is checked in various places, in
>> particular in while-loops, so the long loops are terminated when it
>> is
>> reset.
>
> Good point, although I don't see -[BDSKAsynchronousDOServer
> shouldKeepRunning] used in any loops at this time. Probably worth a
> comment in the code.
You're right. It is checked at a few points to avoid doing unnecessary
things though. Might make sense to check it together with
keepEnumerating in BDSKOrphanedFileServer.
I've added a note in stopDOServer.
>
>
>> That's very important. For example the file content search
>> index can take an hour, so it is important that it knows when it's no
>> longer needed.
>
> Did you change file content search to use BDSKAsynchronousDOServer
> instead of a queue?
>
> --
> adam
No, I forgot that's using its own setup. I just remembered that it
checks a similar flag in its implementation.
BTW, I forgot to ask. I don't understand this in the async DO server:
SInt32 result = CFRunLoopRunInMode(kCFRunLoopDefaultMode,
0.1, TRUE);
if (kCFRunLoopRunFinished == result || kCFRunLoopRunStopped
== result)
OSAtomicCompareAndSwap32Barrier(0, 1, &serverFlags-
>shouldKeepRunning);
else
OSMemoryBarrier();
How could shouldKeepRunning ever become 0 in this (except for the
server being canceled)? Why doesn't this work:
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
untilDate:[NSDate dateWithTimeIntervalSinceDate:0.1]];
OSMemoryBarrier();
Also, is the NSZoneCAlloc for the flags necessary? Shouldn't calloc be
implied by the aligned? We don't do this with extra aligned flags in
subclasses.
Christiaan
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Bibdesk-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop