@@ -50,7 +50,7 @@ type t = {
5050 uring : io_job Uring .t ;
5151 mem : Uring.Region .t option ;
5252 io_q : (t -> unit ) Queue .t ; (* waiting for room on [uring] *)
53- mem_q : Uring.Region .chunk Suspended .t Queue .t ;
53+ mem_q : Uring.Region .chunk Eio.Private.Single_waiter .t Queue .t ;
5454
5555 (* The queue of runnable fibers ready to be resumed. Note: other domains can also add work items here. *)
5656 run_q : runnable Lf_queue .t ;
@@ -74,9 +74,9 @@ type t = {
7474type _ Effect.t + =
7575 | Enter : (t -> 'a Suspended .t -> unit ) -> 'a Effect .t
7676 | Cancel : io_job Uring .job -> unit Effect .t
77- | Alloc : Uring.Region .chunk option Effect .t
78- | Alloc_or_wait : Uring.Region .chunk Effect .t
79- | Free : Uring.Region .chunk -> unit Effect .t
77+ | Get : t Effect .t
78+
79+ let get () = Effect. perform Get
8080
8181let wake_buffer =
8282 let b = Bytes. create 8 in
@@ -339,21 +339,6 @@ and complete_rw_req st ({len; cur_off; action; _} as req) res =
339339 | _ , Exactly len -> Suspended. continue action len
340340 | n , Upto _ -> Suspended. continue action n
341341
342- let alloc_buf_or_wait st k =
343- match st.mem with
344- | None -> Suspended. discontinue k (Failure " No fixed buffer available" )
345- | Some mem ->
346- match Uring.Region. alloc mem with
347- | buf -> Suspended. continue k buf
348- | exception Uring.Region. No_space ->
349- Queue. push k st.mem_q;
350- schedule st
351-
352- let free_buf st buf =
353- match Queue. take_opt st.mem_q with
354- | None -> Uring.Region. free buf
355- | Some k -> enqueue_thread st k buf
356-
357342let rec enqueue_poll_add fd poll_mask st action =
358343 Trace. log " poll_add" ;
359344 let retry = with_cancel_hook ~action st (fun () ->
@@ -411,8 +396,9 @@ let run ~extra_effects st main arg =
411396 Fiber_context. destroy fiber;
412397 Printexc. raise_with_backtrace ex (Printexc. get_raw_backtrace () )
413398 );
414- effc = fun (type a ) (e : a Effect.t ) ->
399+ effc = fun (type a ) (e : a Effect.t ) : (( a , _ ) continuation -> _ ) option ->
415400 match e with
401+ | Get -> Some (fun k -> continue k st)
416402 | Enter fn -> Some (fun k ->
417403 match Fiber_context. get_error fiber with
418404 | Some e -> discontinue k e
@@ -467,22 +453,6 @@ let run ~extra_effects st main arg =
467453 Eio_unix.Private.Thread_pool. submit st.thread_pool ~ctx: fiber ~enqueue fn;
468454 schedule st
469455 )
470- | Alloc -> Some (fun k ->
471- match st.mem with
472- | None -> continue k None
473- | Some mem ->
474- match Uring.Region. alloc mem with
475- | buf -> continue k (Some buf)
476- | exception Uring.Region. No_space -> continue k None
477- )
478- | Alloc_or_wait -> Some (fun k ->
479- let k = { Suspended. k; fiber } in
480- alloc_buf_or_wait st k
481- )
482- | Free buf -> Some (fun k ->
483- free_buf st buf;
484- continue k ()
485- )
486456 | e -> extra_effects.effc e
487457 }
488458 in
0 commit comments