You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: releases.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,34 @@
5
5
- Ruby v3.1 support is dropped.
6
6
-`Async::Wrapper` which was previously deprecated, is now removed.
7
7
8
+
### Flexible Timeouts
9
+
10
+
When {ruby Async::Scheduler#with_timeout} is invoked with a block, it can receive a {ruby Async::Timeout} instance. This allows you to adjust or cancel the timeout while the block is executing. This is useful for long-running tasks that may need to adjust their timeout based on external factors.
11
+
12
+
```ruby
13
+
Asyncdo
14
+
Async::Scheduler.with_timeout(5) do |timeout|
15
+
# Do some work that may take a while...
16
+
17
+
if some_condition
18
+
timeout.cancel! # Cancel the timeout
19
+
else
20
+
# Add 10 seconds to the current timeout:
21
+
timeout.adjust(10)
22
+
23
+
# Reduce the timeout by 10 seconds:
24
+
timeout.adjust(-10)
25
+
26
+
# Set the timeout to 10 seconds from now:
27
+
timeout.duration =10
28
+
29
+
# Increase the current duration:
30
+
timeout.duration +=10
31
+
end
32
+
end
33
+
end
34
+
```
35
+
8
36
## v2.23.0
9
37
10
38
- Rename `ASYNC_SCHEDULER_DEFAULT_WORKER_POOL` to `ASYNC_SCHEDULER_WORKER_POOL`.
0 commit comments