Convert the Callback_Tuple to hold a Socket_Type to be passed back into the callback
You can apparently use To_C (Sock) to get a C.int file descriptor, but you can't turn that back into a Socket_Type. Rats.
This commit is contained in:
parent
ade4bb22d8
commit
59716b5ba8
|
@ -7,9 +7,9 @@
|
|||
package body Async.Epoll is
|
||||
|
||||
procedure Register (This : in out Hub;
|
||||
Descriptor : in C.int;
|
||||
Cb : in Callback_Tuple) is
|
||||
Event : aliased Epoll_Event;
|
||||
Descriptor : constant C.int := C.int (GNAT.Sockets.To_C (Cb.Socket));
|
||||
begin
|
||||
Validate_Hub (This);
|
||||
|
||||
|
@ -62,7 +62,7 @@ package body Async.Epoll is
|
|||
Callback_Registry.Element (This.Callbacks,
|
||||
Natural (Descriptor));
|
||||
begin
|
||||
Cb.Callback.all (Descriptor, Cb.Context);
|
||||
Cb.Callback.all (Cb.Socket, Cb.Context);
|
||||
end;
|
||||
end loop;
|
||||
end Wait_Loop;
|
||||
|
|
|
@ -2,22 +2,24 @@
|
|||
-- Main interface for dealing with epoll(7) from Ada
|
||||
--
|
||||
|
||||
with Interfaces.C,
|
||||
Ada.Containers.Vectors;
|
||||
with Ada.Containers.Vectors,
|
||||
Interfaces.C,
|
||||
GNAT.Sockets;
|
||||
|
||||
use Ada.Containers,
|
||||
Interfaces;
|
||||
use Interfaces,
|
||||
Ada.Containers;
|
||||
|
||||
private with System;
|
||||
|
||||
package Async.Epoll is
|
||||
type Context_Type is tagged null record;
|
||||
type Callback_Type is access procedure (Descriptor : C.int; Context : Context_Type);
|
||||
type Callback_Type is access procedure (Sock : GNAT.Sockets.Socket_Type; Context : Context_Type);
|
||||
|
||||
-- Callback_Tuple is just an arbitrary record to carry the Callback_Type
|
||||
-- and the Context_Type to be passed into that Callback_Type along through
|
||||
-- the Callback_Registry.
|
||||
type Callback_Tuple is record
|
||||
Socket : GNAT.Sockets.Socket_Type;
|
||||
Callback : Callback_Type;
|
||||
Context : Context_Type;
|
||||
end record;
|
||||
|
@ -28,7 +30,6 @@ package Async.Epoll is
|
|||
type Hub is tagged private;
|
||||
|
||||
procedure Register (This : in out Hub;
|
||||
Descriptor : in C.int;
|
||||
Cb : in Callback_Tuple);
|
||||
procedure Run (This : in Hub);
|
||||
|
||||
|
|
Loading…
Reference in New Issue