ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:101217] [Ruby master Feature#17363] Timeouts
@ 2020-12-03 14:58 marcandre-ruby-core
  2020-12-03 15:11 ` [ruby-core:101220] " merch-redmine
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: marcandre-ruby-core @ 2020-12-03 14:58 UTC (permalink / raw)
  To: ruby-core

Issue #17363 has been reported by marcandre (Marc-Andre Lafortune).

----------------------------------------
Feature #17363: Timeouts
https://bugs.ruby-lang.org/issues/17363

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
----------------------------------------
Builtin methods like `Queue.pop` and `Ractor.receive` have no timeout parameter.

We should either:
- provide such a parameter
- and/or provide a `Timeout::wake` that raises an timeout error only if the block is currently sleeping.

Details:

```ruby
q = Queue.new
# ...
elem = Timeout::timeout(42) { q.pop } # => It is possible that an element is retreived from the queue but never stored in `elem`

elem = Timeout::wake(42) { q.pop } # => Guaranteed that either element is retrieved from the queue or an exception is raised, never both
Timeout::wake(42) { loop {} } # => infinite loop
# and/or
elem = q.pop(timeout: 42)
```

Currently, the only reliable way to have a Queue that accepts a timeout is to re-implement it from scratch. This post describe how involved that can be: https://spin.atomicobject.com/2017/06/28/queue-pop-with-timeout-fixed/



-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2022-05-14  9:06 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 14:58 [ruby-core:101217] [Ruby master Feature#17363] Timeouts marcandre-ruby-core
2020-12-03 15:11 ` [ruby-core:101220] " merch-redmine
2020-12-03 19:04 ` [ruby-core:101224] " eregontp
2020-12-04  3:20 ` [ruby-core:101236] " nobu
2020-12-10  8:19 ` [ruby-core:101367] " ko1
2020-12-10  8:20 ` [ruby-core:101368] " ko1
2020-12-10 10:37 ` [ruby-core:101378] " marcandre-ruby-core
2020-12-10 11:45 ` [ruby-core:101383] " eregontp
2020-12-10 11:48 ` [ruby-core:101384] " marcandre-ruby-core
2020-12-10 11:53 ` [ruby-core:101386] " eregontp
2020-12-11  5:48 ` [ruby-core:101415] " marcandre-ruby-core
2020-12-11 10:35 ` [ruby-core:101416] " nobu
2020-12-13 12:29 ` [ruby-core:101436] " eregontp
2020-12-13 12:30 ` [ruby-core:101437] " eregontp
2021-01-12  7:31 ` [ruby-core:102024] " ko1
2021-02-11 23:30 ` [ruby-core:102465] " samuel
2021-02-16 13:25 ` [ruby-core:102538] " naruse
2021-03-31 18:34 ` [ruby-core:103130] " eregontp
2022-05-14  9:06 ` [ruby-core:108551] " Eregon (Benoit Daloze)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).