Re: Thread safety of NSPipe
Re: Thread safety of NSPipe
- Subject: Re: Thread safety of NSPipe
- From: Charles Srstka <email@hidden>
- Date: Thu, 11 Mar 2004 00:15:48 -0600
On Feb 18, 2004, at 8:12 AM, Glen Low wrote:
Consider the following scenario:
1. Main thread creates an NSPipe.
2. Main thread creates a writing NSFileHandle.
3. Main thread creates a reading NSFileHandle and detaches a worker
thread, passing it the NSFileHandle.
4. Main thread writes to the writing NSFileHandle.
5. Worker thread reads from the reading NSFileHandle.
Am I going to get corrupted data? In all cases, operations are
performed on different threads on different objects. (Deallocating the
NSPipe seems problematic, but if it is a static variable, it doesn't
need to get deallocated.)
I should think that this would work, since this is basically what
happens when you use -[NSFileHandle readInBackgroundAndNotify], isn't
it? A worker thread gets spawned which reads from the NSFileHandle.
Charles
_______________________________________________
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.