FileHandle in Threads
FileHandle in Threads
- Subject: FileHandle in Threads
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Thu, 5 Oct 2006 20:48:12 +0200
I have an app with 2 thread: main and reader.
Main opens an NSFileHandle and writes to the file (actually a serial
port) then passes the NSFileHandle to the reader thread for reading.
This fails because the reader thread does not really get a file
handle, but rather an NSDistantObject acting as proxy for the file
handle. [fileHandle availableData] creates an exception complaining
about proxies.
So far so good.
Now I pass the file descriptor to the reader, and it does
NSFileHandle *f = [[NSFileHandle alloc] initWithFileDescriptor: fd
closeOnDealloc: YES];
(the main thread did exactly the same).
Is this a problem: having two file handles pointing to the same file
descriptor?
(It seems to be working - but is this just luck or solidly based on
good design?)
And: should both threads use closeOnDealloc: YES, or just one?
(Again: having both threads using YES does seem to work).
Gerriet.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden