Skip to content

Commit 458e798

Browse files
committed
Use cancellation token default value instead of option
1 parent 15d1e68 commit 458e798

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/Compiler/Utilities/Cancellable.fs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,23 @@ open System.Threading
66
[<Sealed>]
77
type Cancellable =
88
[<ThreadStatic; DefaultValue>]
9-
static val mutable private token: CancellationToken option
9+
static val mutable private token: CancellationToken
1010

1111
static member UsingToken(ct) =
1212
let oldCt = Cancellable.token
1313

14-
Cancellable.token <- Some ct
14+
Cancellable.token <- ct
1515

1616
{ new IDisposable with
1717
member this.Dispose() = Cancellable.token <- oldCt
1818
}
1919

2020
static member Token
21-
with get () =
22-
match Cancellable.token with
23-
| None -> CancellationToken.None
24-
| Some ct -> ct
25-
and internal set v = Cancellable.token <- Some v
21+
with get () = Cancellable.token
22+
and internal set v = Cancellable.token <- v
2623

2724
static member CheckAndThrow() =
28-
match Cancellable.token with
29-
| Some token -> token.ThrowIfCancellationRequested()
30-
| _ -> ()
25+
Cancellable.token.ThrowIfCancellationRequested()
3126

3227
namespace Internal.Utilities.Library
3328

0 commit comments

Comments
 (0)