More progress on the Run loop, as in, we're not looping

Need to figure out a way to structure the callbacks such that
consumers can determine whether or not they need to read data, or "accept"
a socket and register the new socket with the hub.

Oof
This commit is contained in:
R. Tyler Croy 2011-02-13 12:12:00 -08:00
parent 0578c9e16a
commit 606c2fe20b
2 changed files with 17 additions and 3 deletions

View File

@ -31,6 +31,7 @@ package body Epoll is
Callback_Registry.Insert (This.Callbacks, Natural(Descriptor), Cb);
end Register;
procedure Run (This : in Hub) is
begin
Validate_Hub (This);
@ -38,15 +39,26 @@ package body Epoll is
while This.Should_Continue loop
Wait_Loop :
declare
Events : Epoll_Event_Array(0 .. 10);
Num_Descriptors : C.int := Epoll_Wait (This.Epoll_Fd, Events, 10, -1);
Max_Events : constant C.int := 10;
Events : Epoll_Event_Array(0 .. C.size_t (Max_Events));
Num_Descriptors : C.int := Epoll_Wait (This.Epoll_Fd,
Events,
Max_Events,
This.Timeout);
begin
null;
if Num_Descriptors < 0 then
raise Epoll_Wait_Failure;
end if;
for Index in 0 .. Num_Descriptors loop
null; -- Do stuff
end loop;
end Wait_Loop;
end loop;
end Run;
function Create return Hub is
Created_Hub : Hub;
Epoll_Fd : C.int;

View File

@ -28,6 +28,7 @@ package Epoll is
Hub_Invalid : exception;
Descriptor_Registration_Falied : exception;
Invalid_Descriptor : exception;
Epoll_Wait_Failure : exception;
private
use Interfaces.C;
@ -37,6 +38,7 @@ package Epoll is
type Hub is tagged record
Epoll_Fd : C.int := -1;
Timeout : C.int := -1;
Should_Continue : Boolean := True;
Debug : Boolean := False;
Callbacks : Callback_Registry.Vector;