Weird interaction between notifications, runloop and downloading through nsurlhandle
Weird interaction between notifications, runloop and downloading through nsurlhandle
- Subject: Weird interaction between notifications, runloop and downloading through nsurlhandle
- From: Gerben Wierda <email@hidden>
- Date: Thu, 17 Oct 2002 13:52:12 +0200
Mac OS X 10.2.1
I have an app that runs quite a number of NSTasks in the backgound.
These NSTask are displayed in a separate 'activities' window. This is
implemented by adding them to an array and using that array as the
table source. The object supplying the datasource asks the tasks for
their description. This works fine.
Now, these tasks may eithe be tasks running a subprocess (NSTask) or a
download (NSURLHandle). These tasks produe information on their status
(like progress in the case of a download). The following strange thing
happens:
When the window is not visible, everything works as expected.
When the window is visible and a task finishes (end of output data or
end of task), the task signals the datasource-object that it has
finished. The datasource object removes the task form the array and the
table view should be refreshed.
But when a download is running at that time (NSURLHandle
loadInBackground), something strange happens. The NSTasks finishes but
the last notification on the output read file handle (or the
notification signalling the end of the task) never arrives. Querying
the task (using sysctl) tells me it has terminated.
As long as the download is running (also constantly updating the table
view and sending refresh messages to it so the progress of the download
is displayed), the notifications for the NSTasks do not arrive.
However, as soon as I either minimize the activities window or I close
it, the (clearly pending) notifications are sent. Downloading still
continues of course. Re-opening the window displays the changed status
of the tasks perfectly. Logging enables me to see that the
notifications are sent at that time.
All of this makes me suspecting that something is happening in the run
loop of my program preventing the Notifications for the
filehandle/process to be sent as long as the download is in progress.
I suspect (but I cannot check this) that the filehandle and process
notifications are put in the queue with a NSPostWhenIdle. That as long
as the download is running the runloop is not idle. That the end of
donwnloads puts the runloop in idle state and the filehandle/process
notifications are sent. The closing or minimizing of the window puts
stuff in the runloop to be handled ASAP. Somehow that triggers the
posting of the filehandle notifications.
Without access to the NSRunLoop code and given the minimalistic
documentation on this point I cannot figure out what th esource of of
this behaviour and how my app triggers it. I cannot consider this a
Cocoa bug, but it is definitely a problem for me that I cannot inspect
the NotificationCenter, Queue, NSRunLoop more in detail to find out
what is going wrong.
Is there someone who can think of a way to a) fnd out what is actually
happening or b) a workaround?
Yours,
G
_______________________________________________
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.