Forum: JRuby Thread#wakeup in JRuby 1.3.0

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4d5b5dd4e263d780a5dfe7ac8b8ac98c?d=identicon&s=25 Tim Pease (Guest)
on 2009-06-09 17:33
(Received via mailing list)
Thread#wakeup does not appear to be working in JRuby 1.3.0

$> cat test.rb
STDOUT.sync = true
Thread.abort_on_exception = true

t = Thread.new {
  start = Time.now
  loop {
    puts 'sleeping'
    sleep 5
    puts "wake up {Time.now-start}"
    break if Thread.current[:stop]
  }
}

sleep 0.3
puts 'stopping'
t[:stop] = true
t.wakeup.join

$> jruby test.rb
sleeping
stopping
wake up [5.015]

$> ruby test.rb
sleeping
stopping
wake up [0.300945]

$> jruby --version
jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (OpenJDK Client VM
1.6.0_0) [i386-java]

$> java -version
java version "1.6.0_0"
OpenJDK Runtime Environment (IcedTea6 1.5) (fedora-18.b16.fc10-i386)
OpenJDK Client VM (build 14.0-b15, mixed mode)

The output from the second run is what I would expect JRuby to produce
as well. The wakeup call to the other thread is not causing it to
break out of the sleep statement. So we just sit there till the full 5
second sleep time has elapsed (instead of waking up immediately and
then breaking out of the loop).

Thanks for JRuby!

Blessings,
TwP

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2009-06-09 18:03
(Received via mailing list)
On Tue, Jun 9, 2009 at 10:32 AM, Tim Pease<tim.pease@gmail.com> wrote:
> Thread#wakeup does not appear to be working in JRuby 1.3.0

Yep, I saw the bug filed :) We'll have a look at it as soon as we're
able, and if you can figure anything out you'd obviously help speed
that process along.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
4d5b5dd4e263d780a5dfe7ac8b8ac98c?d=identicon&s=25 Tim Pease (Guest)
on 2009-06-09 19:53
(Received via mailing list)
On Tue, Jun 9, 2009 at 9:53 AM, Charles Oliver
Nutter<headius@headius.com> wrote:
> On Tue, Jun 9, 2009 at 10:32 AM, Tim Pease<tim.pease@gmail.com> wrote:
>> Thread#wakeup does not appear to be working in JRuby 1.3.0
>
> Yep, I saw the bug filed :) We'll have a look at it as soon as we're
> able, and if you can figure anything out you'd obviously help speed
> that process along.
>

Thanks, Charlie!

Just wondering if it only occurs on my machine or if it is systemic
with JRuby 1.3.0 on any platform. Anyone else out there want to
confirm?

I'll look into it as best I can -- my Java-fu has many years of dust
upon it. All these @ symbols in the Java code, though, remind me of
Ruby; so that makes me happy ;)

Blessings,
TwP

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2009-06-09 21:21
(Received via mailing list)
On Tue, Jun 9, 2009 at 12:53 PM, Tim Pease<tim.pease@gmail.com> wrote:
> Just wondering if it only occurs on my machine or if it is systemic
> with JRuby 1.3.0 on any platform. Anyone else out there want to
> confirm?
>
> I'll look into it as best I can -- my Java-fu has many years of dust
> upon it. All these @ symbols in the Java code, though, remind me of
> Ruby; so that makes me happy ;)

I'm pretty sure it's systemic...the logic for making sure sleeps
continue to week when "spurious" woken was still in place although
other parts of the logic that would indicate a normal wakeup were
removed.

I'm currently looking at doing sleeps the way MRI does, by doing a
select on nothing. It should be possible to have the same semantics
without the grossitude of the other version.

I think we're going to need a 0.0.1 release for this, since the two
known threading issues combined are pretty cumbersome and will
probably affect a lot of people.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2009-06-09 22:24
(Received via mailing list)
On Tue, Jun 9, 2009 at 2:20 PM, Charles Oliver
Nutter<headius@headius.com> wrote:
> known threading issues combined are pretty cumbersome and will
> probably affect a lot of people.

I have a trivial local fix for this and I'm writing a test for it. I
think someone needs to do a pass over various thread wakeup scenarios
and write tests/specs for it. This is the second case of an obvious
breakage that was not caught by either tests or specs. I'm going to
get a test in for this and then try to write up some tests for a few
other cases.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
F1d37642fdaa1662ff46e4c65731e9ab?d=identicon&s=25 Charles Nutter (headius)
on 2009-06-10 01:59
(Received via mailing list)
On Tue, Jun 9, 2009 at 3:23 PM, Charles Oliver
Nutter<headius@headius.com> wrote:
> I have a trivial local fix for this and I'm writing a test for it. I
> think someone needs to do a pass over various thread wakeup scenarios
> and write tests/specs for it. This is the second case of an obvious
> breakage that was not caught by either tests or specs. I'm going to
> get a test in for this and then try to write up some tests for a few
> other cases.

I have committed a fix and test for this case in 0fe97c2. I'm going to
look at building out a few more cases with selects and so on to try to
add where we don't have good testing. Frustrating thing.

I think we've decided we'll either have a 1.3.1 or a really fast 1.4
to get this out the door quickly. I just want to make sure it's done
right.

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
4d5b5dd4e263d780a5dfe7ac8b8ac98c?d=identicon&s=25 Tim Pease (Guest)
on 2009-06-10 05:03
(Received via mailing list)
On Tue, Jun 9, 2009 at 5:59 PM, Charles Oliver
Nutter<headius@headius.com> wrote:
> look at building out a few more cases with selects and so on to try to
> add where we don't have good testing. Frustrating thing.
>
> I think we've decided we'll either have a 1.3.1 or a really fast 1.4
> to get this out the door quickly. I just want to make sure it's done
> right.
>

Great job!

I vote for a point build. 'Tis a bug fix.

Blessings,
TwP

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.