event driven vs blocking
event driven vs blocking
- Subject: event driven vs blocking
- From: Chris Silverberg <email@hidden>
- Date: Mon, 13 May 2002 14:28:52 -0700
- Organization: Aladdin Systems, Inc.
Hi folks,
First, thanks to the folks at WWDC for putting on some excellent networking
sessions. Now that some of the concepts have sunk in, I'm trying to figure
out the best way advance my application's use of Networking and I have a
general question about event driven vs blocking.
Some background... my application is Carbon based using Open Transport and
Thread Manager (ie: cooperative threads). The implementation uses the
PowerPlant networking classes. My application will make a minimum of three
connections, and a maximum of 11. Of those connections, 1-4 will involve
sending large amounts of data simultaneously in both directions. The other
connections will be only send much smaller messages and will often sit idle.
As you can imagine I don't get very good performance on MacOS X because of
OT and cooperative threading... and I manage to consume way too much CPU at
the same time. So I want to migrate to using CFStream.
As currently implemented, each of my connections is implemented as a
blocking thread. (Underneath, it's actually using async open transport, but
as far as my code is concerned, it's a blocking method). I should be able
to easily migrate my code to CFStream since the behavior is very similar.
But I'm concerned about running up to eleven preemptive threads. The
message I seem to be hearing from Apple is, for best performance DON'T do
this... instead use the event-driven approach with a single thread.
The difficulty that I see there is, on first look event driven looks rather
easy... until you consider that it's really a very different approach. I'd
be curious to see how a protocol such as SMTP would be implemented using an
event driven approach. It seems like it's going to be difficult to
structure that code. (The samples I have seen show HTTP which is really a
very simple protocol... there's just a single send data, receive data... no
back and forth like you'd see in SMTP.)
So, here's the bottom line question... should I really avoid (or not even
consider) creating 11 threads because of performance considerations? Or is
this still a reasonable approach... maybe not as efficient as event driven,
but much less complex and therefore a good solution?
thanks,
Chris
_______________________________________________
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.
References: | |
| >Re: CFSocket (From: Douglas Davidson <email@hidden>) |