forked from ocurrent/ocurrent
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add `Pool.of_fn` so that users can provide their own pools. This allows waiting for resources from an external service before marking a job as started.
- Loading branch information
Showing
10 changed files
with
133 additions
and
91 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
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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
type t | ||
type 'a t | ||
|
||
type priority = [ `High | `Low ] | ||
|
||
val create : label:string -> int -> t | ||
val create : label:string -> int -> unit t | ||
|
||
val of_fn : | ||
label : string -> | ||
(priority:priority -> switch:Switch.t -> 'a Lwt.t * (unit -> unit Lwt.t)) -> | ||
'a t | ||
|
||
val get : | ||
'a t -> | ||
priority:priority -> | ||
on_cancel:((string -> unit Lwt.t) -> unit Lwt.t) -> | ||
switch:Switch.t -> | ||
t -> unit Lwt.t | ||
(** [get ~priority ~on_cancel ~switch t] waits for a resource and then returns. | ||
'a Lwt.t * (unit -> unit Lwt.t) | ||
(** [get ~priority ~switch t] waits for a resource and then returns. | ||
It also returns a function that can be used to cancel the request. | ||
The resource will be returned to the pool when [switch] is turned off. *) | ||
|
||
val pp : t Fmt.t | ||
val pp : _ t Fmt.t |
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
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