Hi Jordan,

On Feb 3, 2010, at 12:43 PM, Jordan K. Hubbard wrote:

> On Feb 3, 2010, at 10:13 AM, MacRuby wrote:
> 
>> Using a copy of the array "sometimes" works, but I'm not quite sure how or
>> why.  Still, the technical answer is that attempting to modify a dynamic
>> object inside a GCD leads to "undefined"  behavior, so I'll mark this as
>> "behaves correctly". :-/
> 
> I think this is going to be a perennial problem until we figure out some 
> idiom for accessing variables from within GCD code (preferably something 
> terse which can be easily taught, in the vein of @synchronized).  Ruby 
> programmers are just too used to having a GIL pay for their sins. :-(

Haven't you been paying attention to trunk? :-)

http://svn.macosforge.org/repository/ruby/MacRuby/trunk/lib/dispatch/dispatch.rb


  # Wrap the passed +obj+ (or its instance) inside an Actor to serialize access
  # and allow asynchronous invocation plus a callback
  def wrap(obj)
    Dispatch::Actor.new( (obj.is_a? Class) ? obj.new : obj)
  end

http://svn.macosforge.org/repository/ruby/MacRuby/trunk/lib/dispatch/actor.rb

i.e.,
-----
require 'dispatch'

serialized_array = Dispatch.wrap(Array)

----

Would that do it for you?

-- Ernie  P.

_______________________________________________
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to