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: kotlinx-coroutines-core/common/src/Timeout.kt
+12-9
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,7 @@ import kotlin.time.*
17
17
/**
18
18
* Runs a given suspending [block] of code inside a coroutine with a specified [timeout][timeMillis] and throws
19
19
* a [TimeoutCancellationException] if the timeout was exceeded.
20
+
* If the given [timeMillis] is non-positive, [TimeoutCancellationException] is thrown immediately.
20
21
*
21
22
* The code that is executing inside the [block] is cancelled on timeout and the active or next invocation of
22
23
* the cancellable suspending function inside the block throws a [TimeoutCancellationException].
@@ -25,8 +26,8 @@ import kotlin.time.*
25
26
* Note that the timeout action can be specified for a [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
26
27
*
27
28
* **The timeout event is asynchronous with respect to the code running in the block** and may happen at any time,
28
-
* even right before the return from inside of the timeout [block]. Keep this in mind if you open or acquire some
29
-
* resource inside the [block] that needs closing or release outside of the block.
29
+
* even right before the return from inside the timeout [block]. Keep this in mind if you open or acquire some
30
+
* resource inside the [block] that needs closing or release outside the block.
30
31
* See the
31
32
* [Asynchronous timeout and resources][https://kotlinlang.org/docs/reference/coroutines/cancellation-and-timeouts.html#asynchronous-timeout-and-resources]
32
33
* section of the coroutines guide for details.
@@ -48,6 +49,7 @@ public suspend fun <T> withTimeout(timeMillis: Long, block: suspend CoroutineSco
48
49
/**
49
50
* Runs a given suspending [block] of code inside a coroutine with the specified [timeout] and throws
50
51
* a [TimeoutCancellationException] if the timeout was exceeded.
52
+
* If the given [timeout] is non-positive, [TimeoutCancellationException] is thrown immediately.
51
53
*
52
54
* The code that is executing inside the [block] is cancelled on timeout and the active or next invocation of
53
55
* the cancellable suspending function inside the block throws a [TimeoutCancellationException].
@@ -56,8 +58,8 @@ public suspend fun <T> withTimeout(timeMillis: Long, block: suspend CoroutineSco
56
58
* Note that the timeout action can be specified for a [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
57
59
*
58
60
* **The timeout event is asynchronous with respect to the code running in the block** and may happen at any time,
59
-
* even right before the return from inside of the timeout [block]. Keep this in mind if you open or acquire some
60
-
* resource inside the [block] that needs closing or release outside of the block.
61
+
* even right before the return from inside the timeout [block]. Keep this in mind if you open or acquire some
62
+
* resource inside the [block] that needs closing or release outside the block.
61
63
* See the
62
64
* [Asynchronous timeout and resources][https://kotlinlang.org/docs/reference/coroutines/cancellation-and-timeouts.html#asynchronous-timeout-and-resources]
63
65
* section of the coroutines guide for details.
@@ -74,6 +76,7 @@ public suspend fun <T> withTimeout(timeout: Duration, block: suspend CoroutineSc
74
76
/**
75
77
* Runs a given suspending block of code inside a coroutine with a specified [timeout][timeMillis] and returns
76
78
* `null` if this timeout was exceeded.
79
+
* If the given [timeMillis] is non-positive, `null` is returned immediately.
77
80
*
78
81
* The code that is executing inside the [block] is cancelled on timeout and the active or next invocation of
79
82
* cancellable suspending function inside the block throws a [TimeoutCancellationException].
@@ -82,8 +85,8 @@ public suspend fun <T> withTimeout(timeout: Duration, block: suspend CoroutineSc
82
85
* Note that the timeout action can be specified for a [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
83
86
*
84
87
* **The timeout event is asynchronous with respect to the code running in the block** and may happen at any time,
85
-
* even right before the return from inside of the timeout [block]. Keep this in mind if you open or acquire some
86
-
* resource inside the [block] that needs closing or release outside of the block.
88
+
* even right before the return from inside the timeout [block]. Keep this in mind if you open or acquire some
89
+
* resource inside the [block] that needs closing or release outside the block.
87
90
* See the
88
91
* [Asynchronous timeout and resources][https://kotlinlang.org/docs/reference/coroutines/cancellation-and-timeouts.html#asynchronous-timeout-and-resources]
89
92
* section of the coroutines guide for details.
@@ -114,6 +117,7 @@ public suspend fun <T> withTimeoutOrNull(timeMillis: Long, block: suspend Corout
114
117
/**
115
118
* Runs a given suspending block of code inside a coroutine with the specified [timeout] and returns
116
119
* `null` if this timeout was exceeded.
120
+
* If the given [timeout] is non-positive, `null` is returned immediately.
117
121
*
118
122
* The code that is executing inside the [block] is cancelled on timeout and the active or next invocation of
119
123
* cancellable suspending function inside the block throws a [TimeoutCancellationException].
@@ -122,8 +126,8 @@ public suspend fun <T> withTimeoutOrNull(timeMillis: Long, block: suspend Corout
122
126
* Note that the timeout action can be specified for a [select] invocation with [onTimeout][SelectBuilder.onTimeout] clause.
123
127
*
124
128
* **The timeout event is asynchronous with respect to the code running in the block** and may happen at any time,
125
-
* even right before the return from inside of the timeout [block]. Keep this in mind if you open or acquire some
126
-
* resource inside the [block] that needs closing or release outside of the block.
129
+
* even right before the return from inside the timeout [block]. Keep this in mind if you open or acquire some
130
+
* resource inside the [block] that needs closing or release outside the block.
127
131
* See the
128
132
* [Asynchronous timeout and resources][https://kotlinlang.org/docs/reference/coroutines/cancellation-and-timeouts.html#asynchronous-timeout-and-resources]
129
133
* section of the coroutines guide for details.
@@ -177,7 +181,6 @@ public class TimeoutCancellationException internal constructor(
0 commit comments