Re: To thread or not to thread?
Re: To thread or not to thread?
- Subject: Re: To thread or not to thread?
- From: Becky Willrich <email@hidden>
- Date: Mon, 17 Feb 2003 10:39:42 -0800
I have a very general question: I am working on a distributed text
editor that currently uses one thread for everything, i.e. one
runloop for keyboard events as well as network i/o. Now I've realized
that at the moment some runloop modes (selecting text) prevent the
network events from getting through and thus the socket buffer may
run full.
So what is your opinion: Is it better to introduce a designated
thread for handling network events or to try to ensure that no
operation or mode blocks the runloop for too much time?
Yes, using a dedicated thread for network operation is necessary in
that case.
Not necessarily - if you schedule the network I/O on
kCFRunLoopCommonModes, then the I/O events will come through the run
loop in any mode the AppKit uses for temporary event tracking (which I
assume is why the text selection is blocking the I/O events). The
bigger risk is that whatever processing is being done in response to
the run loop will take longer than you want to hold up other run loop
events - either the processing of data from the network events takes
longer than you want to starve UI events, or vice versa. If that
happens, you really will need a second thread. But it's worth trying
the single thread model - as long as you don't do any lengthy
processing when data arrives or when a user event is processed, you
should be o.k.
REW
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.