mirror of
https://github.com/ocaml-multicore/eio.git
synced 2025-08-11 00:02:22 -04:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1dce15f1aa | ||
|
7d6e96adf9 | ||
|
c837066650 | ||
|
895cbc4578 |
@ -213,35 +213,37 @@ let test_signal_race () =
|
|||||||
|
|
||||||
let test_alloc_fixed_or_wait () =
|
let test_alloc_fixed_or_wait () =
|
||||||
Eio_linux.run ~n_blocks:1 @@ fun _env ->
|
Eio_linux.run ~n_blocks:1 @@ fun _env ->
|
||||||
let block = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
match Eio_linux.Low_level.alloc_fixed_or_wait () with
|
||||||
(* We have to wait for the block, but get cancelled while waiting. *)
|
| exception (Failure "No fixed buffer available") [@warning "-52"] -> Alcotest.skip ()
|
||||||
begin
|
| block ->
|
||||||
try
|
(* We have to wait for the block, but get cancelled while waiting. *)
|
||||||
Fiber.both
|
begin
|
||||||
(fun () -> ignore (Eio_linux.Low_level.alloc_fixed_or_wait () : Uring.Region.chunk))
|
try
|
||||||
(fun () -> raise Exit);
|
Fiber.both
|
||||||
with Exit -> ()
|
(fun () -> ignore (Eio_linux.Low_level.alloc_fixed_or_wait () : Uring.Region.chunk))
|
||||||
end;
|
(fun () -> raise Exit);
|
||||||
(* We have to wait for the block, and get it when the old one is freed. *)
|
with Exit -> ()
|
||||||
Fiber.both
|
end;
|
||||||
(fun () ->
|
(* We have to wait for the block, and get it when the old one is freed. *)
|
||||||
let x = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
Fiber.both
|
||||||
Eio_linux.Low_level.free_fixed x
|
(fun () ->
|
||||||
)
|
let x = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
||||||
(fun () ->
|
Eio_linux.Low_level.free_fixed x
|
||||||
Eio_linux.Low_level.free_fixed block
|
)
|
||||||
);
|
(fun () ->
|
||||||
(* The old block is passed to the waiting fiber, but it's cancelled. *)
|
Eio_linux.Low_level.free_fixed block
|
||||||
let block = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
);
|
||||||
Fiber.both
|
(* The old block is passed to the waiting fiber, but it's cancelled. *)
|
||||||
(fun () ->
|
let block = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
||||||
Fiber.first
|
Fiber.both
|
||||||
(fun () -> ignore (Eio_linux.Low_level.alloc_fixed_or_wait ()); assert false)
|
(fun () ->
|
||||||
(fun () -> ())
|
Fiber.first
|
||||||
)
|
(fun () -> ignore (Eio_linux.Low_level.alloc_fixed_or_wait ()); assert false)
|
||||||
(fun () -> Eio_linux.Low_level.free_fixed block);
|
(fun () -> ())
|
||||||
let block = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
)
|
||||||
Eio_linux.Low_level.free_fixed block
|
(fun () -> Eio_linux.Low_level.free_fixed block);
|
||||||
|
let block = Eio_linux.Low_level.alloc_fixed_or_wait () in
|
||||||
|
Eio_linux.Low_level.free_fixed block
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
let open Alcotest in
|
let open Alcotest in
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
(* See the end of the file for the license *)
|
|
||||||
external stub_write : Unix.file_descr -> Cstruct.t -> int = "eio_windows_cstruct_write"
|
|
||||||
|
|
||||||
let rec write fd buf =
|
|
||||||
if Cstruct.length buf > 0 then begin
|
|
||||||
let n = stub_write fd buf in
|
|
||||||
write fd @@ Cstruct.shift buf n
|
|
||||||
end
|
|
||||||
|
|
||||||
let writev fd bufs = List.iter (write fd) bufs
|
|
||||||
|
|
||||||
external read : Unix.file_descr -> Cstruct.t -> int = "eio_windows_cstruct_read"
|
|
||||||
|
|
||||||
(* From mirage/ocaml-cstruct
|
|
||||||
Copyright (c) 2012 Anil Madhavapeddy <anil@recoil.org>
|
|
||||||
Copyright (c) 2012 Pierre Chambart
|
|
||||||
Copyright (c) Christiano F. Haesbaert <haesbaert@haesbaert.org>
|
|
||||||
Copyright (c) Citrix Inc
|
|
||||||
Copyright (c) David Sheets <sheets@alum.mit.edu>
|
|
||||||
Copyright (c) Drup <drupyog@zoho.com>
|
|
||||||
Copyright (c) Hannes Mehnert <hannes@mehnert.org>
|
|
||||||
Copyright (c) Jeremy Yallop <yallop@gmail.com>
|
|
||||||
Copyright (c) Mindy Preston <meetup@yomimono.org>
|
|
||||||
Copyright (c) Nicolas Ojeda Bar <n.oje.bar@gmail.com>
|
|
||||||
Copyright (c) Richard Mortier <mort@cantab.net>
|
|
||||||
Copyright (c) Rudi Grinberg <rudi.grinberg@gmail.com>
|
|
||||||
Copyright (c) Thomas Gazagnaire <thomas@gazagnaire.com>
|
|
||||||
Copyright (c) Thomas Leonard <talex5@gmail.com>
|
|
||||||
Copyright (c) Vincent Bernardoff <vb@luminar.eu.org>
|
|
||||||
Copyright (c) pqwy <david@numm.org>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *)
|
|
Loading…
x
Reference in New Issue
Block a user