The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
RubyCocoa 64-bit and threading issues (part one)

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Laurent Sansonetti

Posts: 134
Nickname: lrz
Registered: Jun, 2006

Laurent Sansonetti is a software engineer at Apple Computer and a longtime Ruby enthusiast.
RubyCocoa 64-bit and threading issues (part one) Posted: Apr 1, 2007 10:02 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Laurent Sansonetti.
Original Post: RubyCocoa 64-bit and threading issues (part one)
Feed Title: lrz's diary
Feed URL: http://www.chopine.be/lrz/diary/xml/rss/feed.xml
Feed Description: lrz's diary
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Laurent Sansonetti
Latest Posts From lrz's diary

Advertisement

Recently on the RubyCocoa front, I have been working on making it functional under a 64-bit environment.

First the metadata generator had to be modified to produce 64-bit annotations, as some elements may have a different encoding type or value depending on the architecture. At the same time the generator is now able to handle endianness-specific elements, that may be different on a PPC and i386 machine.

Secondly, the version of the libffi library that we use had to be ported to 64-bit. I took an existing port of x86_64 and adapted it for the Mac OS X ABI. ppc64 support is still missing.

And finally, the bridge itself had to be adapted to support 64-bit related things, like pointer conversions. This was fairly easy to do.The result is pretty gratifying, it's like putting all the pieces of a puzzle together. The samples are now working great on 64-bit.

On the other side, I worked on a pretty annoying issue related to threading. One of the biggest issue with Ruby 1.8 is that the runtime isn't thread-safe. It means that you cannot call the Ruby runtime in a thread that isn't the main one. And this of course is problematic when Ruby is bridged to Objective-C, because some Cocoa classes are susceptible to callback you in a thread. And you crash.

The solution would be of course to make Ruby thread-safe, but this isn't easy, and Ruby 1.9 should be thread-safe. So an interim solution is to route threaded messages from Objective-C into the main thread. This isn't ideal as it may impact the performance (or even more serious, cause a deadlock). But it's still better than crashing.

There is a second recurrent threading issue, related to the Ruby threading model implementation, that I will discuss later in a separate post.

Read: RubyCocoa 64-bit and threading issues (part one)

Topic: Scheduling tasks in Ruby / Rails Previous Topic   Next Topic Topic: The last TextMate theme you'll ever need

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use