Re: NSFileHandle and thread safety

2016-07-27 Thread Jan E. Schotsman
On Jul 25, 2016, at 9:37 PM, Daniel Stenmark wrote: 1. Can I write to two different files using two NSFIleHandles from two threads at the same time? Yes. 2. Can I read from a single file using two NSFileHandles on two threads at the same time? Why would you need to do that in the first

Re: NSFileHandle and thread safety

2016-07-25 Thread Daniel Stenmark
> As long as each thread has a separate file handle, they’re independent of > each other, since each file handle remembers its own offset in the file. Ah, durr, you’re right. Apologies, I once had the displeasure of debugging an ancient codebase that used the same Unix file descriptor with

Re: NSFileHandle and thread safety

2016-07-25 Thread Jens Alfke
> On Jul 25, 2016, at 12:37 PM, Daniel Stenmark wrote: > > 2. Can I read from a single file using two NSFileHandles on two threads at > the same time? > > Why would you need to do that in the first place? To get multithreaded access to the file contents. This is

Re: NSFileHandle and thread safety

2016-07-25 Thread Graham Cox
> On 26 Jul 2016, at 5:37 AM, Daniel Stenmark wrote: > > 2. Can I read from a single file using two NSFileHandles on two threads at > the same time? > > Why would you need to do that in the first place? Unless you’re reading a > single byte at a time, it sounds like

Re: NSFileHandle and thread safety

2016-07-25 Thread Daniel Stenmark
1. Can I write to two different files using two NSFIleHandles from two threads at the same time? Yes. 2. Can I read from a single file using two NSFileHandles on two threads at the same time? Why would you need to do that in the first place? Unless you’re reading a single byte at a time, it