• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
FileHandle in Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: FileHandle in Threads
      • From: AgentM <email@hidden>
  • Prev by Date: Always use the constants (was Re: Finding all deleted objects from Core Data)
  • Next by Date: Re: FileHandle in Threads
  • Previous by thread: NSManagedObjectContext Multiple Selection Error
  • Next by thread: Re: FileHandle in Threads
  • Index(es):
    • Date
    • Thread