mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 11:15:38 -05:00
wip: move Chan to sync, use events
This commit is contained in:
parent
0b8415436f
commit
0c41866c9a
5 changed files with 24 additions and 8 deletions
|
|
@ -22,7 +22,6 @@ module Atomic = Atomic_
|
||||||
module Blocking_queue = Bb_queue
|
module Blocking_queue = Bb_queue
|
||||||
module Background_thread = Background_thread
|
module Background_thread = Background_thread
|
||||||
module Bounded_queue = Bounded_queue
|
module Bounded_queue = Bounded_queue
|
||||||
module Chan = Chan
|
|
||||||
module Exn_bt = Exn_bt
|
module Exn_bt = Exn_bt
|
||||||
module Fifo_pool = Fifo_pool
|
module Fifo_pool = Fifo_pool
|
||||||
module Fut = Fut
|
module Fut = Fut
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@ val await : 'a Fut.t -> 'a
|
||||||
|
|
||||||
module Lock = Lock
|
module Lock = Lock
|
||||||
module Fut = Fut
|
module Fut = Fut
|
||||||
module Chan = Chan
|
|
||||||
module Task_local_storage = Task_local_storage
|
module Task_local_storage = Task_local_storage
|
||||||
module Thread_local_storage = Thread_local_storage
|
module Thread_local_storage = Thread_local_storage
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
module A = Atomic_
|
open Moonpool
|
||||||
|
module A = Moonpool_private.Atomic_
|
||||||
|
|
||||||
type 'a or_error = 'a Fut.or_error
|
type 'a or_error = 'a Fut.or_error
|
||||||
type 'a waiter = 'a Fut.promise
|
type 'a waiter = 'a Fut.promise
|
||||||
|
|
@ -97,7 +98,7 @@ let push (self : _ t) x : unit =
|
||||||
true
|
true
|
||||||
| Elems q -> not (A.compare_and_set self.st old_st (Elems (Q.push q x)))
|
| Elems q -> not (A.compare_and_set self.st old_st (Elems (Q.push q x)))
|
||||||
do
|
do
|
||||||
Domain_.relax ()
|
Moonpool_private.Domain_.relax ()
|
||||||
done
|
done
|
||||||
|
|
||||||
let try_pop (type elt) self : elt option =
|
let try_pop (type elt) self : elt option =
|
||||||
|
|
@ -115,7 +116,7 @@ let try_pop (type elt) self : elt option =
|
||||||
if A.compare_and_set self.st old_st new_st then
|
if A.compare_and_set self.st old_st new_st then
|
||||||
raise_notrace (M.Found x)
|
raise_notrace (M.Found x)
|
||||||
else
|
else
|
||||||
Domain_.relax ()
|
Moonpool_private.Domain_.relax ()
|
||||||
| _ -> raise_notrace Exit
|
| _ -> raise_notrace Exit
|
||||||
done;
|
done;
|
||||||
None
|
None
|
||||||
|
|
@ -152,7 +153,7 @@ let pop (type elt) (self : _ t) : elt Fut.t =
|
||||||
raise_notrace (M.Fut fut));
|
raise_notrace (M.Fut fut));
|
||||||
true
|
true
|
||||||
do
|
do
|
||||||
Domain_.relax ()
|
Moonpool_private.Domain_.relax ()
|
||||||
done;
|
done;
|
||||||
(* never reached *)
|
(* never reached *)
|
||||||
assert false
|
assert false
|
||||||
|
|
@ -180,7 +181,7 @@ let close (self : _ t) : unit =
|
||||||
) else
|
) else
|
||||||
true
|
true
|
||||||
do
|
do
|
||||||
Domain_.relax ()
|
Moonpool_private.Domain_.relax ()
|
||||||
done
|
done
|
||||||
|
|
||||||
[@@@ifge 5.0]
|
[@@@ifge 5.0]
|
||||||
|
|
@ -190,4 +191,10 @@ let pop_await self =
|
||||||
| Some x -> x
|
| Some x -> x
|
||||||
| None -> Fut.await @@ pop self
|
| None -> Fut.await @@ pop self
|
||||||
|
|
||||||
|
let[@inline] pop_ev self : _ Event.t =
|
||||||
|
Event.from_request {
|
||||||
|
request=fun comp k ->
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
[@@@endif]
|
[@@@endif]
|
||||||
|
|
@ -9,6 +9,8 @@
|
||||||
@since 0.3
|
@since 0.3
|
||||||
*)
|
*)
|
||||||
|
|
||||||
|
open Moonpool
|
||||||
|
|
||||||
type 'a or_error = 'a Fut.or_error
|
type 'a or_error = 'a Fut.or_error
|
||||||
|
|
||||||
type 'a t
|
type 'a t
|
||||||
|
|
@ -49,4 +51,12 @@ val pop_await : 'a t -> 'a
|
||||||
available. See {!Fut.await} for more details.
|
available. See {!Fut.await} for more details.
|
||||||
@since 0.3 *)
|
@since 0.3 *)
|
||||||
|
|
||||||
|
val pop_ev : 'a t -> 'a Event.t
|
||||||
|
(** Pop from the channel, as an event.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
|
val push_ev : 'a t -> 'a -> unit Event.t
|
||||||
|
(** Push into the channel, as an event.
|
||||||
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
[@@@endif]
|
[@@@endif]
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
module Mutex = Picos_std_sync.Mutex
|
module Mutex = Picos_std_sync.Mutex
|
||||||
module Condition = Picos_std_sync.Condition
|
module Condition = Picos_std_sync.Condition
|
||||||
module Lock = Lock
|
module Lock = Lock
|
||||||
module Event = Picos_std_event
|
module Event = Event
|
||||||
module Semaphore = Picos_std_sync.Semaphore
|
module Semaphore = Picos_std_sync.Semaphore
|
||||||
module Lazy = Picos_std_sync.Lazy
|
module Lazy = Picos_std_sync.Lazy
|
||||||
module Latch = Picos_std_sync.Latch
|
module Latch = Picos_std_sync.Latch
|
||||||
module Ivar = Picos_std_sync.Ivar
|
module Ivar = Picos_std_sync.Ivar
|
||||||
module Stream = Picos_std_sync.Stream
|
module Stream = Picos_std_sync.Stream
|
||||||
|
module Chan = Chan
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue