native threads in ruby

Discussion in 'Ruby' started by Rick Penn, Jan 16, 2008.

  1. Rick Penn

    Rick Penn Guest

    Is there anyway possible, one can make use of native threads in Ruby?
    Maybe by interfacing with C or Java?
    --
    Posted via http://www.ruby-forum.com/.
     
    Rick Penn, Jan 16, 2008
    #1
    1. Advertising

  2. Rick Penn wrote:
    > Is there anyway possible, one can make use of native threads in Ruby?
    > Maybe by interfacing with C or Java?


    JRuby supports native threads today, where each Ruby thread maps to one
    native thread. There's also a second option, native thread pooling,
    where the number of native threads used is only ever as high as the
    number of threads running concurrently.

    Normal native thread support is the default. Pooling can be enabled with
    a command-line option:

    -J-Djruby.thread.pooling=true

    - Charlie
     
    Charles Oliver Nutter, Jan 16, 2008
    #2
    1. Advertising

  3. [Note: parts of this message were removed to make it a legal post.]

    On Jan 16, 2008 6:12 AM, Charles Oliver Nutter <>
    wrote:

    > Rick Penn wrote:
    > > Is there anyway possible, one can make use of native threads in Ruby?
    > > Maybe by interfacing with C or Java?

    >
    > JRuby supports native threads today, where each Ruby thread maps to one
    > native thread. There's also a second option, native thread pooling,
    > where the number of native threads used is only ever as high as the
    > number of threads running concurrently.
    >
    > Normal native thread support is the default. Pooling can be enabled with
    > a command-line option:
    >
    > -J-Djruby.thread.pooling=true
    >
    > - Charlie
    >
    >

    --enable-threading will put 1.8.6 in native thread mode, but it is unadvised
    to do so. Ruby 1.9 does uses native threads as well as a construct called
    Fibers, which I think are a better implementation of 1.8.6's green threads.

    Jason
     
    Jason Roelofs, Jan 16, 2008
    #3
  4. Rick Penn

    Tom M Guest

    On Jan 16, 7:23 am, Jason Roelofs <> wrote:
    > [Note: parts of this message were removed to make it a legal post.]
    >
    > On Jan 16, 2008 6:12 AM, Charles Oliver Nutter <>
    > wrote:
    >
    >
    >
    > > Rick Penn wrote:
    > > > Is there anyway possible, one can make use of native threads in Ruby?
    > > > Maybe by interfacing with C or Java?

    >
    > > JRuby supports native threads today, where each Ruby thread maps to one
    > > native thread. There's also a second option, native thread pooling,
    > > where the number of native threads used is only ever as high as the
    > > number of threads running concurrently.

    >
    > > Normal native thread support is the default. Pooling can be enabled with
    > > a command-line option:

    >
    > > -J-Djruby.thread.pooling=true

    >
    > > - Charlie

    >
    > --enable-threading will put 1.8.6 in native thread mode, but it is unadvised
    > to do so. Ruby 1.9 does uses native threads as well as a construct called
    > Fibers, which I think are a better implementation of 1.8.6's green threads.
    >
    > Jason


    I believe that while 1.9 does support native threads, their benefit is
    minimal as there is a global interpreter lock most of the time. Is
    that correct?
     
    Tom M, Jan 16, 2008
    #4
  5. Tom M wrote:
    > I believe that while 1.9 does support native threads, their benefit is
    > minimal as there is a global interpreter lock most of the time. Is
    > that correct?


    That is correct. Ruby 1.9 runs with native threads, but they don't run
    concurrently.

    - Charlie
     
    Charles Oliver Nutter, Jan 16, 2008
    #5
  6. Rick Penn

    Rick Penn Guest

    It looks like I'll be using JRuby. Does JRuby have all the features that
    Ruby 1.8.6 has? Are there any plans to incorporate the features in 1.9
    to JRuby?

    Thanks,
    Ryan
    --
    Posted via http://www.ruby-forum.com/.
     
    Rick Penn, Jan 17, 2008
    #6
  7. We've done the best job we can making JRuby compatible with Ruby
    1.8.6, and hopefully others can attest to that. The only major feature
    missing is Continuations, which are a little sketchy with native
    threads anyway.

    As for 1.9 features, we already have some. For example, we have a port
    of the regexp engine 1.9 uses, and a native-thread-backed
    implementation of Fibers. We probably won't include more before the
    JRuby 1.1 release later this month, but we'll add as many as possible
    after that, including all of 1.9's specific optimizations and support
    for abitrarily-encoded strings.

    - Charlie

    On Jan 16, 2008, at 19:18, Rick Penn <> wrote:

    > It looks like I'll be using JRuby. Does JRuby have all the features
    > that
    > Ruby 1.8.6 has? Are there any plans to incorporate the features in 1.9
    > to JRuby?
    >
    > Thanks,
    > Ryan
    > --
    > Posted via http://www.ruby-forum.com/.
    >
     
    Charles Oliver Nutter, Jan 17, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yoda
    Replies:
    2
    Views:
    471
    =?utf-8?Q?Bj=C3=B6rn_Lindstr=C3=B6m?=
    Aug 1, 2005
  2. Nataraj M Basppa

    Monitoring native threads using JNI

    Nataraj M Basppa, Feb 5, 2007, in forum: Java
    Replies:
    3
    Views:
    607
    Gordon Beaton
    Feb 5, 2007
  3. Voroztsov Artem
    Replies:
    0
    Views:
    201
    Voroztsov Artem
    Nov 24, 2007
  4. Deb 123
    Replies:
    2
    Views:
    124
    Deb 123
    Feb 20, 2008
  5. Tom M
    Replies:
    1
    Views:
    117
    Roger Pack
    Nov 11, 2008
Loading...

Share This Page