-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reworked async search/filter UI code to avoid noticeable lag due to w…
…aiting for cancellations that take too long
- Loading branch information
Showing
10 changed files
with
295 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
type 'a t = { | ||
lock : Eio.Mutex.t; | ||
mutable data : 'a option; | ||
} | ||
|
||
let make () = | ||
{ | ||
lock = Eio.Mutex.create (); | ||
data = None; | ||
} | ||
|
||
let set (t : 'a t) (x : 'a) = | ||
Eio.Mutex.use_rw t.lock ~protect:false (fun () -> | ||
t.data <- Some x | ||
) | ||
|
||
let unset (t : 'a t) = | ||
Eio.Mutex.use_rw t.lock ~protect:false (fun () -> | ||
t.data <- None | ||
) | ||
|
||
let get (t : 'a t) : 'a option = | ||
Eio.Mutex.use_rw t.lock ~protect:false (fun () -> | ||
let x = t.data in | ||
t.data <- None; | ||
x | ||
) |
Oops, something went wrong.