File: alog-protected_containers.ads

## Documentation

Table of Contents
Class Inheritance Tree

1.     --

2.     --  Copyright (c) 2009,

3.     --  Reto Buerki, Adrian-Ken Rueegsegger

4.     --

5.     --  This file is part of Alog.

6.     --

7.     --  Alog is free software; you can redistribute it and/or modify

8.     --  it under the terms of the GNU Lesser General Public License as published

9.     --  by the Free Software Foundation; either version 2.1 of the License, or

10.     --  (at your option) any later version.

11.     --

12.     --  Alog is distributed in the hope that it will be useful,

13.     --  but WITHOUT ANY WARRANTY; without even the implied warranty of

14.     --  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

15.     --  GNU Lesser General Public License for more details.

16.     --

17.     --  You should have received a copy of the GNU Lesser General Public License

18.     --  along with Alog; if not, write to the Free Software

19.     --  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,

20.     --  MA  02110-1301  USA

21.     --

23.     with Ada.Containers.Doubly_Linked_Lists;

25.     with Alog.Log_RequestTo API docTo specTo body;

27.     --  Alog Protected Containers. This package provides protected containers which

28.     --  are safe for concurrent access.

29.     package Alog.Protected_ContainersTo API docTo specTo body is

31.        ----------------------

32.        -- Log_Request_List --

33.        ----------------------

35.        type Log_Request_StorageTo API docTo body is private;

37.        protected type Log_Request_List is

39.           procedure PutTo API docTo body (ElementTo API docTo body : Log_Request.InstanceTo API docTo specTo body);

40.           --  Put an element at the end of the request list.

42.           entry GetTo API docTo body (Element : out Log_Request.InstanceTo API docTo specTo body);

43.           --  Get the first element from the list (and delete it).

45.           procedure DoneTo API docTo body;

46.           --  Signal successfull processing of request previously gotten from list.

48.           entry All_DoneTo API docTo body;

49.           --  This procedure blocks until the list is empty and there are no

50.           --  pending requests. A requests is pending when it is taken off the list

51.           --  via Get but it's successfull processing has not been signaled back

52.           --  via the procedure Done.

54.           procedure ClearTo API docTo body;

55.           --  Clear the request list by deleting all log requests.

57.           function LengthTo API docTo body return Natural;

58.           --  Return the number of elements in the list.

60.           function PendingTo API docTo body return Natural;

61.           --  Return the number of pending requests.

63.        private

65.           Requests           : Log_Request_StorageTo API docTo specTo body;

66.           Requests_Available : Boolean := False;

67.           Pending_Counter    : Natural := 0;

69.        end Log_Request_ListTo API docTo spec;

70.        --  Protected variant of a log request list. This list holds log request

71.        --  objects and is safe for concurrent access. It operates in FIFO-Mode.

73.     private

75.        use type Alog.Log_Request.InstanceTo API docTo specTo body;

77.        package List_Of_Log_Requests_Package is

78.          new Ada.Containers.Doubly_Linked_Lists

79.            (Element_Type => Log_Request.InstanceTo API docTo specTo body);

81.        package LOLRP renames List_Of_Log_Requests_Package;

83.        type Log_Request_StorageTo API docTo spec is new LOLRP.List with null record;

85.     end Alog.Protected_ContainersTo API docTo specTo body;