/usr/share/ada/adainclude/anet/anet-sockets-tasking.ads is in libanet0.1-dev 0.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | --
-- Copyright (C) 2012 secunet Security Networks AG
-- Copyright (C) 2012 Reto Buerki <reet@codelabs.ch>
-- Copyright (C) 2012 Adrian-Ken Rueegsegger <ken@codelabs.ch>
--
-- This program is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; either version 2 of the License, or (at your
-- option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-- for more details.
--
-- As a special exception, if other files instantiate generics from this
-- unit, or you link this unit with other files to produce an
-- executable this unit does not by itself cause the resulting
-- executable to be covered by the GNU General Public License. This
-- exception does not however invalidate any other reasons why the
-- executable file might be covered by the GNU Public License.
--
with Ada.Exceptions;
package Anet.Sockets.Tasking is
type Count_Type is mod System.Max_Binary_Modulus;
type Rcv_Item_Callback is not null access procedure
(Item : Ada.Streams.Stream_Element_Array;
Src : Socket_Addr_Type);
-- Data reception callback procedure. The Item argument contains the
-- received data, the Src argument identifies the sender of the data.
type Error_Handler_Callback is not null access procedure
(E : Ada.Exceptions.Exception_Occurrence;
Stop_Flag : in out Boolean);
-- Error handling callback procedure. E is the exception to handle. The
-- stop flag signals the receiver to stop listening for data and terminate.
type Receiver_Type (S : not null access Socket_Type) is limited private;
-- Listens for incoming data on the given socket and processes it by
-- calling the registered listen callback.
function Get_Rcv_Msg_Count (Receiver : Receiver_Type) return Count_Type;
-- Returns the number of received and processed messages.
procedure Listen
(Receiver : in out Receiver_Type;
Callback : Rcv_Item_Callback);
-- Start listening for data on given socket. The given callback is
-- asynchronously executed upon data reception. Call stop procedure to
-- properly shutdown the receiver.
procedure Register_Error_Handler
(Receiver : in out Receiver_Type;
Callback : Error_Handler_Callback);
-- Register given callback for error handling. The error handler will be
-- invoked if an exception occurs processing incoming data.
-- The error handler must be registered before telling the receiver to
-- listen for data.
procedure Stop (Receiver : in out Receiver_Type);
-- Stop listening for data.
function Is_Listening (Receiver : Receiver_Type) return Boolean;
-- Returns True if the receiver is currently listening for data.
private
protected type Trigger_Type is
procedure Activate;
-- Activate trigger.
procedure Shutdown;
-- Signal shutdown to all tasks waiting on the Stop entry.
entry Stop;
-- Entry used for listener ATC.
procedure Signal_Termination;
-- Signal termination to all tasks waiting on the Wait_For_Termination
-- entry.
entry Wait_For_Termination;
-- Wait until termination is signaled.
function Is_Listening return Boolean;
-- Returns true if the receiver task is currently listening for data.
private
Shutdown_Requested : Boolean := False;
Is_Terminated : Boolean := True;
end Trigger_Type;
-- This trigger is used to terminate the receiver task by means of ATC.
task type Receiver_Task (Parent : not null access Receiver_Type) is
entry Listen (Cb : Rcv_Item_Callback);
-- Start listening for data on parent's socket. The callback procedure
-- is called upon reception of new data.
entry Set_Error_Handler (Cb : Error_Handler_Callback);
-- Register given callback for error handling. The error handler will be
-- invoked if an exception occurs processing incoming data.
-- The task will cease to listen for data if the callback signals it to
-- terminate by setting the Stop flag to True.
end Receiver_Task;
type Receiver_Type (S : not null access Socket_Type) is limited record
Item_Count : Count_Type := 0;
pragma Atomic (Item_Count);
Trigger : Trigger_Type;
R_Task : Receiver_Task (Parent => Receiver_Type'Access);
end record;
end Anet.Sockets.Tasking;
|