Project

General

Profile

Bug #16608

ConditionVariable#wait should return false when timeout exceeded

Added by shugo (Shugo Maeda) 2 months ago. Updated 2 months ago.

Status:
Assigned
Priority:
Normal
Target version:
-
[ruby-core:97063]

Description

The following program prints false on Ruby 1.8, but true on Ruby 1.9 or later.

require "monitor"
m = Monitor.new
c = m.new_cond
m.synchronize { p c.wait(0.1) }

However, it's not critical because most programs check the condition after wait.

Updated by shugo (Shugo Maeda) 2 months ago

  • Assignee set to shugo (Shugo Maeda)
  • Status changed from Open to Assigned

Updated by shugo (Shugo Maeda) 2 months ago

  • Assignee changed from shugo (Shugo Maeda) to nobu (Nobuyoshi Nakada)

nobu (Nobuyoshi Nakada) wrote in #note-2:

How about https://github.com/ruby/ruby/pull/2884

ko1 suggested Mutex#release (new version of Mutex#sleep) for backward compatibility.
What do you think of it?

Updated by Eregon (Benoit Daloze) 2 months ago

shugo (Shugo Maeda) wrote in #note-3:

ko1 suggested Mutex#release (new version of Mutex#sleep) for backward compatibility.

release sounds like unlock as in acquire/release is similar to lock/unlock.
So I think we need a different name there.

I'm not sure about backward compatibility, but I would think it's fine to change the return value here as probably almost nothing uses it.

Also available in: Atom PDF