spawn_24.0.0_8f4c2fa8/source/spawn/spawn-polls-posix_polls.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--
--  Copyright (C) 2022, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

private with Ada.Containers.Hashed_Maps;

package Spawn.Polls.POSIX_Polls is

   type POSIX_Poll is new Poll with private;

private

   type Info is record
      Events   : Watch_Event_Set;
      Listener : Listener_Access;
   end record;

   function Hash (V : Descriptor) return Ada.Containers.Hash_Type is
     (Ada.Containers.Hash_Type'Mod (V));

   package Info_Maps is new Ada.Containers.Hashed_Maps
     (Descriptor, Info, Hash, Interfaces.C."=");

   type POSIX_Poll is new Poll with record
      Initialized : Boolean := False;
      Map         : Info_Maps.Map;
   end record;

   overriding function Is_Initialized (Self : POSIX_Poll) return Boolean;

   overriding procedure Initialize (Self : out POSIX_Poll);

   overriding procedure Watch
     (Self     : in out POSIX_Poll;
      Value    : Descriptor;
      Events   : Watch_Event_Set;
      Listener : Listener_Access := null);

   overriding procedure Wait
     (Self    : in out POSIX_Poll;
      Timeout : Duration);

end Spawn.Polls.POSIX_Polls;