On Dec 26, 2007, at 5:01 PM, Christiaan Hofman wrote:

>
> On 27 Dec 2007, at 1:47 AM, Adam R. Maxwell wrote:
>
>>
>> On Dec 26, 2007, at 4:11 PM, Christiaan Hofman wrote:
>>
>>>
>>> On 26 Dec 2007, at 9:11 PM, Adam R. Maxwell wrote:
>>>
>>>>
>>> Could BDSKSearchIndex be simplified by making it a subclass
>>> of BDSKAsynchronousDOServer?
>>
>> I don't think there's much benefit at this point; it would basically
>> replace a few ivars with others.  Right now it's about as simple and
>> lightweight as you can get, since there are no NSConnections or
>> NSInvocations involved.  Since all the updates are received via
>> notifications anyway, the queue/port approach works pretty well.  If
>> we need more complicated interthread messaging in future, using a
>> BDSKAsynchronousDOServer would likely be more straightforward.
>>
>> --   
>> adam
>>
>
> It could make the code a bit simpler and easier to read, I think.
> There would be no need for the notification queue and port as well as
> the lock, and the whole runIndexThread method could be removed.

It could be removed in that case, but that's only because those ivars  
and code (and much, much more) are already in  
BDSKAsynchronousDOServer.  Using the NSMachPort alone has a lot less  
overhead (no NSInvocation), and I think it's actually simpler in this  
case, because the notifications are designed for queuing.

> Notifications could just be forwarded to the server thread.

Conceptually, yes.  They might have to be converted to some other form  
if they encode byref, since that's pretty slow...I've never tried  
passing notifications between threads.  That would have to be checked.

> processNotification is a bit weird (it should probably be split into
> a main thread and a worker thread method, as all notifications are
> initially received ion the main thread and processed through
> handleMachMessage: on the worker thread).

It could probably be refactored somehow, but it's pretty simple.  That  
part of the implementation was basically taken directly from Apple's  
documentation:

http://developer.apple.com/documentation/Cocoa/Conceptual/Notifications/Articles/Threading.html

It handles cases where the notification is posted on any thread, which  
doesn't affect us any longer (but it will work in any case).



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bibdesk-develop mailing list
Bibdesk-develop@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bibdesk-develop

Reply via email to