[MacRuby-devel] Thread safety in apply example?

Charles Oliver Nutter headius at headius.com
Mon Jan 24 17:09:13 PST 2011


On Mon, Jan 24, 2011 at 11:26 AM, Joshua Ballanco <jballanc at gmail.com> wrote:
> On Mon, Jan 24, 2011 at 12:15 PM, Charles Oliver Nutter
> <headius at headius.com> wrote:
>>
>> Queue#apply is actually defined in gcd.c in MacRuby's code, so this
>> would be a MacRuby bug. I'd have filed it, but I wasn't sure if I was
>> missing something about MacRuby's Array and thread-safety.
>
> Yeah, probably a documentation bug...but only sorta. Parallel/Not-Parallel
> will depend on the queue. Apply just queues the block asynchronously the
> number of times indicated by the argument. How the block executes depends on
> the queue.

Ok, that makes sense. The documentation implied that apply always runs
the jobs in parallel, so I assumed that meant they could potentially
run concurrently. If instead they're serial, the example as written
should be safe.

It seems like a poor example in any case, however, since someone might
assume using a concurrent queue is safe as well.

- Charlie


More information about the MacRuby-devel mailing list