Re: OTCreateSystemTask() Replacement?
Re: OTCreateSystemTask() Replacement?
- Subject: Re: OTCreateSystemTask() Replacement?
- From: "Mike Cohen" <email@hidden>
- Date: Sat, 7 Apr 2007 23:10:18 -0400
There's no such thing as non-preemptive threads in OS X. The unix way
to do that would be to have a separate thread either calling select()
or a blocking read on the socket. SystemTask doesn't exist in OS X;
it's simply provided as a hack for older code. New code should use
native OS X threading with runloops.
There's a very good reason to avoid OS 9-style event handling. If you
call WaitNextEvent and other old-style event manager calls your
application will use a lot more CPU time and will slow down the system
a lot. When you use blocking I/O, CFRunloop, or select, your
application will use no CPU time when it's blocked.
On 4/7/07, email@hidden <email@hidden> wrote:
On Apr 7, 2007, at 8:21 PM, Josh Graessley wrote:
> Are you trying to develop for Mac OS X or Mac OS 9?
>
> For Mac OS X, you should seriously consider switching to a
> CFRunLoop and using sockets and CFSocket to handle networking.
>
> NewThread, OTCreateSystemTask, WaitNextEvent, SystemTask are all a
> compatibility shim to keep old code limping along. They are not
> intended for new code development.
This is for OS X. I started working on networking back in the 90s
when it was still a nightmare on the Mac, so it messed up my
methodologies. Now I am just calling sockets directly, but the
problem is really logistics now since I have a udp class that needs
to have its Idle() function called periodically for polling. It has
several dozen functions so it's not feasible to make the whole thing
preemptive. For example, it would just die right now if I called Idle
() from another preemptive thread. It should be perfectly legal to
call Idle() during a dialog's system task time though. Such a thing
should still exist on the mac, since countless programs bring up
dialog boxes in their main thread. If it doesn't, then it got axed
for political reasons and I just don't know how much more of that I
can take.
I guess what I am trying to say is, if the notion of system task time
doesn't exist anymore, then we can't really write nonblocking code on
the main thread that can coexist with system gui elements. I think
that's a big deal, and I hope that there is a way to do it.
------------------------------------------------------------------------
Zack Morris Z Sculpt Entertainment This Space
email@hidden http://www.zsculpt.com For Rent
------------------------------------------------------------------------
If the doors of perception were cleansed, everything would appear to man
as it is, infinite. -William Blake, The Marriage of Heaven and Hell
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden