Reformatting,

Test_Event modified to support command line scripting
Suppressed dependencies on Tasking.Soft_Links

[Imported from Perforce change 6546 at 2006-12-01 19:55:37]

Subversion-branch: /trunk/polyorb
Subversion-revision: 34512
This commit is contained in:
Jérôme Hugues
2003-03-25 13:36:44 +00:00
parent bbb5273d83
commit 4df2eebbdc
28 changed files with 1201 additions and 872 deletions

View File

@@ -2,20 +2,20 @@ AUTOMAKE_OPTIONS = no-dependencies
include $(srcdir)/../Makefile.common
#COS_GNATMAKE_FLAGS = -I$(srcdir) \
# -I../naming \
# -I$(srcdir)/../naming \
# -I$(COS_ROOT)/event \
# -I$(COS_ROOT)/naming \
# -I../../src \
# -I$(srcdir)/../../src
COS_GNATMAKE_FLAGS=-I../../idls/cos/naming \
-I../naming \
-I../../idls/cos/event
# le fichier que l'on veut générer
# pour l'instant il s'agit d'un fichier qui fait des tests
PROGS=test_event
corba_exe=test_event
COS_GNATMAKE_FLAGS = \
-I$(srcdir) \
-I../naming \
-I$(srcdir)/../naming \
-I$(COS_ROOT)/event \
-I$(COS_ROOT)/naming \
-I../../src \
-I$(srcdir)/../../src \
-I../../idls/cos/naming \
-I../../idls/cos/event
PROGS=@APPLI_EXES@
FORCE= force

22
cos/event/README Normal file
View File

@@ -0,0 +1,22 @@
README for PolyORB's COS Event Service
---------------------------------------
$Id: //droopi/main/cos/event/README#1 $
PolyORB provides a default implementation of the CORBA COS Event
Service.
The executable test_event tests its functionnalities.
test_event can be started in
- interactive mode, an online help details the various commande
./test_event
- batch mode,
./test_event <COSNAMING_IOR> <script_file>
script_file is a text file containing the same commands as in
interactive mode, see online help or supplier.cmd file for more details.

View File

@@ -1,25 +1,56 @@
with Ada.Exceptions; use Ada.Exceptions;
------------------------------------------------------------------------------
-- --
-- POLYORB COMPONENTS --
-- --
-- A U T O _ P R I N T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2003 Free Software Fundation --
-- --
-- PolyORB is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. PolyORB is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with PolyORB; see file COPYING. If --
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- 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. --
-- --
-- PolyORB is maintained by ENST Paris University. --
-- --
------------------------------------------------------------------------------
with CosEventComm.PushConsumer.Impl;
use CosEventComm.PushConsumer.Impl;
-- $Id$
with CosEventComm.PushConsumer;
with PortableServer; use PortableServer;
pragma Warnings (Off, PortableServer);
with Ada.Exceptions;
with Ada.Text_IO;
with Ada.Exceptions; use Ada.Exceptions;
with CosEventComm.PushConsumer.Impl;
with CORBA;
use CORBA;
package body Auto_Print is
use Ada.Text_IO;
use Ada.Exceptions;
use CORBA;
use CosEventComm.PushConsumer.Impl;
---------------------------
-- Ensure_Initialization --
---------------------------
T_Initialized : Boolean := False;
procedure Ensure_Initialization is
begin
if T_Initialized then
@@ -30,45 +61,41 @@ package body Auto_Print is
T_Initialized := True;
end Ensure_Initialization;
-------------------------
-- Thread Auto_Display --
-------------------------
procedure Auto_Display
is
Got_Msg : CORBA.Boolean;
Msg : CORBA.Any;
Ptr : PushConsumer.Impl.Object_Ptr;
procedure Auto_Display is
begin
declare
B : CORBA.Boolean;
A : CORBA.Any;
Ptr : PushConsumer.Impl.Object_Ptr;
begin
Ada.Text_IO.Put ("début");
Ensure_Initialization;
Ptr := PushConsumer.Impl.Object_Ptr (A_S);
-- A_S is a global variable used to pass an argument to this task
-- Ptr is initialized
-- we can let For_Consumers go
Enter (Session_Mutex);
Signal (Session_Taken);
Leave (Session_Mutex);
loop
exit when EndDisplay = True;
delay 0.1;
Try_Pull (Ptr, B, A);
if B then
Ada.Text_IO.Put_Line (
To_Standard_String (From_Any (A)));
else
Ada.Text_IO.Put ("");
end if;
end loop;
EndDisplay := False;
exception
when E : others =>
Ada.Text_IO.Put_Line ("raise "& Exception_Name (E));
Ada.Text_IO.Put_Line (Exception_Message (E));
Ada.Text_IO.Put_Line (Exception_Information (E));
end;
Ptr := PushConsumer.Impl.Object_Ptr (A_S);
Enter (Session_Mutex);
Signal (Session_Taken);
Leave (Session_Mutex);
Put_Line ("AutoDisplay setup");
loop
exit when EndDisplay = True;
delay 0.1;
Try_Pull (Ptr, Got_Msg, Msg);
if Got_Msg then
Ada.Text_IO.Put_Line (To_Standard_String (From_Any (Msg)));
end if;
end loop;
EndDisplay := False;
exception
when E : others =>
Ada.Text_IO.Put_Line ("raised "& Exception_Name (E));
Ada.Text_IO.Put_Line (Exception_Message (E));
Ada.Text_IO.Put_Line (Exception_Information (E));
end Auto_Display;
end Auto_Print;

View File

@@ -1,27 +1,57 @@
with CosEventComm; use CosEventComm;
------------------------------------------------------------------------------
-- --
-- POLYORB COMPONENTS --
-- --
-- A U T O _ P R I N T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2003 Free Software Fundation --
-- --
-- PolyORB is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. PolyORB is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with PolyORB; see file COPYING. If --
-- not, write to the Free Software Foundation, 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- 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. --
-- --
-- PolyORB is maintained by ENST Paris University. --
-- --
------------------------------------------------------------------------------
with CORBA;
-- $Id$
with CosEventComm;
with CORBA.Impl;
with PolyORB.Tasking.Mutexes;
with PolyORB.Tasking.Condition_Variables;
use PolyORB.Tasking.Condition_Variables;
use PolyORB.Tasking.Mutexes;
package Auto_Print is
use CosEventComm;
use PolyORB.Tasking.Condition_Variables;
use PolyORB.Tasking.Mutexes;
procedure Auto_Display;
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized
T_Initialized : Boolean := False;
Session_Mutex : Mutex_Access;
Session_Taken : Condition_Access;
-- Synchornisation of task initialization.

View File

@@ -31,7 +31,14 @@
-- --
------------------------------------------------------------------------------
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with CORBA.Sequences.Unbounded;
with PortableServer;
with CosEventChannelAdmin;
with CosEventChannelAdmin.ProxyPullSupplier;
with CosEventChannelAdmin.ProxyPullSupplier.Helper;
@@ -45,25 +52,24 @@ with CosEventChannelAdmin.ConsumerAdmin.Helper;
pragma Elaborate (CosEventChannelAdmin.ConsumerAdmin.Helper);
pragma Warnings (Off, CosEventChannelAdmin.ConsumerAdmin.Helper);
with CosEventChannelAdmin.ConsumerAdmin.Skel;
pragma Elaborate (CosEventChannelAdmin.ConsumerAdmin.Skel);
pragma Warnings (Off, CosEventChannelAdmin.ConsumerAdmin.Skel);
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Mutexes;
with CORBA.Sequences.Unbounded;
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with PortableServer; use PortableServer;
with PolyORB.Log;
package body CosEventChannelAdmin.ConsumerAdmin.Impl is
use PolyORB.Log;
use CosEventChannelAdmin;
use PortableServer;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Tasking.Mutexes;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("consumeradmin");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
@@ -74,13 +80,31 @@ package body CosEventChannelAdmin.ConsumerAdmin.Impl is
package PullSuppliers is
new CORBA.Sequences.Unbounded (ProxyPullSupplier.Impl.Object_Ptr);
type Consumer_Admin_Record is
record
This : Object_Ptr;
Channel : EventChannel.Impl.Object_Ptr;
Pushs : PushSuppliers.Sequence;
Pulls : PullSuppliers.Sequence;
end record;
type Consumer_Admin_Record is record
This : Object_Ptr;
Channel : EventChannel.Impl.Object_Ptr;
Pushs : PushSuppliers.Sequence;
Pulls : PullSuppliers.Sequence;
end record;
---------------------------
-- Ensure_Initialization --
---------------------------
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized.
T_Initialized : Boolean := False;
Self_Mutex : Mutex_Access;
procedure Ensure_Initialization is
begin
if not T_Initialized then
Create (Self_Mutex);
T_Initialized := True;
end if;
end Ensure_Initialization;
------------
-- Create --
@@ -95,11 +119,12 @@ package body CosEventChannelAdmin.ConsumerAdmin.Impl is
begin
pragma Debug (O ("create consumer admin"));
Consumer := new Object;
Consumer.X := new Consumer_Admin_Record;
Consumer := new Object;
Consumer.X := new Consumer_Admin_Record;
Consumer.X.This := Consumer;
Consumer.X.Channel := Channel;
Initiate_Servant (Servant (Consumer), My_Ref);
return Consumer;
end Create;
@@ -117,11 +142,15 @@ package body CosEventChannelAdmin.ConsumerAdmin.Impl is
begin
pragma Debug (O ("obtain proxy pull supplier from consumer admin"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Supplier := ProxyPullSupplier.Impl.Create (Self.X.This);
PullSuppliers.Append (Self.X.Pulls, Supplier);
Leave_Critical_Section;
Leave (Self_Mutex);
Servant_To_Reference (Servant (Supplier), Its_Ref);
return Its_Ref;
end Obtain_Pull_Supplier;
@@ -139,11 +168,15 @@ package body CosEventChannelAdmin.ConsumerAdmin.Impl is
begin
pragma Debug (O ("obtain proxy push supplier from consumer admin"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Supplier := ProxyPushSupplier.Impl.Create (Self.X.This);
PushSuppliers.Append (Self.X.Pushs, Supplier);
Leave_Critical_Section;
Leave (Self_Mutex);
Servant_To_Reference (Servant (Supplier), Its_Ref);
return Its_Ref;
end Obtain_Push_Supplier;
@@ -153,24 +186,28 @@ package body CosEventChannelAdmin.ConsumerAdmin.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any) is
Data : in CORBA.Any) is
begin
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
declare
Pulls : constant PullSuppliers.Element_Array
:= PullSuppliers.To_Element_Array (Self.X.Pulls);
Pushs : constant PushSuppliers.Element_Array
:= PushSuppliers.To_Element_Array (Self.X.Pushs);
begin
Leave_Critical_Section;
Leave (Self_Mutex);
pragma Debug (O ("post new data to proxy pull suppliers"));
for I in Pulls'Range loop
ProxyPullSupplier.Impl.Post (Pulls (I), Data);
for J in Pulls'Range loop
ProxyPullSupplier.Impl.Post (Pulls (J), Data);
end loop;
pragma Debug (O ("post new data to proxy push suppliers"));
for I in Pushs'Range loop
ProxyPushSupplier.Impl.Post (Pushs (I), Data);
for J in Pushs'Range loop
ProxyPushSupplier.Impl.Post (Pushs (J), Data);
end loop;
end;
end Post;

View File

@@ -40,9 +40,7 @@ with PortableServer;
package CosEventChannelAdmin.ConsumerAdmin.Impl is
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
function Obtain_Push_Supplier
@@ -59,7 +57,7 @@ package CosEventChannelAdmin.ConsumerAdmin.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any);
Data : in CORBA.Any);
function Create
(Channel : CosEventChannelAdmin.EventChannel.Impl.Object_Ptr)
@@ -70,9 +68,8 @@ private
type Consumer_Admin_Record;
type Consumer_Admin_Access is access all Consumer_Admin_Record;
type Object is new PortableServer.Servant_Base with
record
X : Consumer_Admin_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Consumer_Admin_Access;
end record;
end CosEventChannelAdmin.ConsumerAdmin.Impl;

View File

@@ -31,6 +31,11 @@
-- --
------------------------------------------------------------------------------
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with PortableServer;
with CosEventChannelAdmin.SupplierAdmin;
with CosEventChannelAdmin.SupplierAdmin.Impl;
@@ -48,44 +53,30 @@ pragma Elaborate (CosEventChannelAdmin.EventChannel.Skel);
pragma Warnings (Off, CosEventChannelAdmin.EventChannel.Skel);
with PolyORB.CORBA_P.Server_Tools;
with PortableServer; use PortableServer;
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with PolyORB.Log;
package body CosEventChannelAdmin.EventChannel.Impl is
use PolyORB.CORBA_P.Server_Tools;
-----------
-- Debug --
-----------
use PolyORB.Log;
use PortableServer;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("eventchannel");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
-------------
-- Channel --
-------------
type Event_Channel_Record is
record
This : Object_Ptr;
Consumer : ConsumerAdmin.Impl.Object_Ptr;
Supplier : SupplierAdmin.Impl.Object_Ptr;
end record;
type Event_Channel_Record is record
This : Object_Ptr;
Consumer : ConsumerAdmin.Impl.Object_Ptr;
Supplier : SupplierAdmin.Impl.Object_Ptr;
end record;
------------
-- Create --
------------
function Create return Object_Ptr
function Create
return Object_Ptr
is
Channel : Object_Ptr;
My_Ref : EventChannel.Ref;
@@ -155,7 +146,7 @@ package body CosEventChannelAdmin.EventChannel.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any) is
Data : in CORBA.Any) is
begin
ConsumerAdmin.Impl.Post (Self.X.Consumer, Data);
end Post;

View File

@@ -34,15 +34,11 @@
with CosEventChannelAdmin.SupplierAdmin;
with CosEventChannelAdmin.ConsumerAdmin;
-- with CosEventChannelAdmin.EventChannel;
with PortableServer;
package CosEventChannelAdmin.EventChannel.Impl is
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
function For_Consumers
@@ -62,7 +58,7 @@ package CosEventChannelAdmin.EventChannel.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any);
Data : in CORBA.Any);
function Create return Object_Ptr;
@@ -71,10 +67,8 @@ private
type Event_Channel_Record;
type Event_Channel_Access is access Event_Channel_Record;
type Object is
new PortableServer.Servant_Base with
record
X : Event_Channel_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Event_Channel_Access;
end record;
end CosEventChannelAdmin.EventChannel.Impl;

View File

@@ -31,11 +31,16 @@
-- --
------------------------------------------------------------------------------
with CosEventComm; use CosEventComm;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PortableServer;
with CosEventComm;
with CosEventComm.PullSupplier;
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CosEventChannelAdmin;
with CosEventChannelAdmin.SupplierAdmin.Impl;
@@ -49,14 +54,7 @@ pragma Warnings (Off, CosEventChannelAdmin.ProxyPullConsumer.Skel);
with CosEventChannelAdmin.SupplierAdmin.Impl;
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with PortableServer; use PortableServer;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Log;
@@ -64,19 +62,32 @@ with PolyORB.Tasking.Threads;
with PolyORB.Tasking.Mutexes;
with PolyORB.Tasking.Condition_Variables;
package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
use CosEventComm;
use CosEventChannelAdmin;
use PortableServer;
use PolyORB.Tasking.Condition_Variables;
use PolyORB.Tasking.Mutexes;
use PolyORB.Tasking.Threads;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Log;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("proxypullconsumer");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
type Proxy_Pull_Consumer_Record is record
This : Object_Ptr;
Peer : PullSupplier.Ref;
Admin : SupplierAdmin.Impl.Object_Ptr;
Engin_Launched : Boolean := False;
-- is there a thread launch for the engine
end record;
A_S : Object_Ptr := null;
-- This variable is used to initialize the threads local variable.
-- it is used to replace the 'accept' statement.
@@ -85,6 +96,9 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
Session_Taken : Condition_Access;
-- Synchornisation of task initialization.
Peer_Mutex : Mutex_Access;
-- Protect access on a peer component
T_Initialized : Boolean := False;
procedure Ensure_Initialization;
@@ -102,31 +116,18 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
end if;
Create (Session_Mutex);
Create (Session_Taken);
Create (Peer_Mutex);
T_Initialized := True;
end Ensure_Initialization;
-- task type Proxy_Pull_Consumer_Engin is
-- entry Connect (Consumer : in Object_Ptr);
-- end Proxy_Pull_Consumer_Engin;
-- type Proxy_Pull_Consumer_Engin_Access is access Proxy_Pull_Consumer_Engin;
type Proxy_Pull_Consumer_Record is
record
This : Object_Ptr;
Peer : PullSupplier.Ref;
Admin : SupplierAdmin.Impl.Object_Ptr;
Engin_Launch : Boolean := False;
-- is there a thread launch for the engine
end record;
-------------------------------
-- Proxy_Pull_Consumer_Engin --
-------------------------------
procedure Proxy_Pull_Consumer_Engin;
procedure Proxy_Pull_Consumer_Engin
procedure Proxy_Pull_Consumer_Engine;
procedure Proxy_Pull_Consumer_Engine
is
This : Object_Ptr;
Peer : PullSupplier.Ref;
@@ -150,9 +151,9 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
loop
-- Session thread main loop.
Enter_Critical_Section;
Enter (Peer_Mutex);
Peer := This.X.Peer;
Leave_Critical_Section;
Leave (Peer_Mutex);
exit when PullSupplier.Is_Nil (Peer);
@@ -170,53 +171,9 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
SupplierAdmin.Impl.Post (This.X.Admin, Event);
end loop;
This.X.Engin_Launch := False;
end Proxy_Pull_Consumer_Engin;
-- task body Proxy_Pull_Consumer_Engin
-- is
-- This : Object_Ptr;
-- Peer : PullSupplier.Ref;
-- Event : CORBA.Any;
-- begin
-- loop
-- select
-- accept Connect
-- (Consumer : Object_Ptr)
-- do
-- This := Consumer;
-- end Connect;
-- or
-- terminate;
-- end select;
--
-- loop
-- Enter_Critical_Section;
-- Peer := This.X.Peer;
-- Leave_Critical_Section;
--
-- exit when PullSupplier.Is_Nil (Peer);
--
-- pragma Debug
-- (O ("pull new data from proxy pull consumer engin"));
--
-- begin
-- Event := PullSupplier.pull (Peer);
-- exception when others =>
-- exit;
-- end;
--
-- pragma Debug
-- (O ("post new data from proxy pull consumer to admin"));
--
-- SupplierAdmin.Impl.Post (This.X.Admin, Event);
-- end loop;
-- end loop;
-- end Proxy_Pull_Consumer_Engin;
This.X.Engin_Launched := False;
end Proxy_Pull_Consumer_Engine;
---------------------------
-- Connect_Pull_Supplier --
@@ -224,10 +181,12 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
procedure Connect_Pull_Supplier
(Self : access Object;
Pull_Supplier : in CosEventComm.PullSupplier.Ref) is
Pull_Supplier : in CosEventComm.PullSupplier.Ref) is
begin
pragma Debug (O ("connect pull supplier to proxy pull consumer"));
Ensure_Initialization;
Enter (Session_Mutex);
if not PullSupplier.Is_Nil (Self.X.Peer) then
Leave (Session_Mutex);
@@ -238,9 +197,9 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
A_S := Self.X.This;
-- Start engin
if Self.X.Engin_Launch = False then
Create_Task (Proxy_Pull_Consumer_Engin'Access);
Self.X.Engin_Launch := True;
if not Self.X.Engin_Launched then
Create_Task (Proxy_Pull_Consumer_Engine'Access);
Self.X.Engin_Launched := True;
-- thread created
end if;
@@ -248,39 +207,15 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
Wait (Session_Taken, Session_Mutex);
Leave (Session_Mutex);
end Connect_Pull_Supplier;
-- procedure Connect_Pull_Supplier
-- (Self : access Object;
-- Pull_Supplier : in CosEventComm.PullSupplier.Ref) is
-- begin
-- pragma Debug (O ("connect pull supplier to proxy pull consumer"));
-- Enter_Critical_Section;
-- if not PullSupplier.Is_Nil (Self.X.Peer) then
-- Leave_Critical_Senction;
-- raise AlreadyConnected;
-- end if;
-- Self.X.Peer := Pull_Supplier;
-- Start engin
-- if Self.X.Engin = null then
-- Self.X.Engin := new Proxy_Pull_Consumer_Engin;
-- end if;
-- Self.X.Engin.Connect (Self.X.This);
-- Leave_Critical_Section;
-- end Connect_Pull_Supplier;
------------
-- Create --
------------
function Create (Admin : SupplierAdmin.Impl.Object_Ptr) return Object_Ptr
function Create
(Admin : SupplierAdmin.Impl.Object_Ptr)
return Object_Ptr
is
Consumer : Object_Ptr;
My_Ref : ProxyPullConsumer.Ref;
@@ -309,10 +244,10 @@ package body CosEventChannelAdmin.ProxyPullConsumer.Impl is
begin
pragma Debug (O ("disconnect proxy pull consumer"));
Enter_Critical_Section;
Enter (Peer_Mutex);
Peer := Self.X.Peer;
Self.X.Peer := Nil_Ref;
Leave_Critical_Section;
Leave (Peer_Mutex);
if not PullSupplier.Is_Nil (Peer) then
PullSupplier.disconnect_pull_supplier (Peer);

View File

@@ -47,7 +47,7 @@ package CosEventChannelAdmin.ProxyPullConsumer.Impl is
procedure Connect_Pull_Supplier
(Self : access Object;
Pull_Supplier : in CosEventComm.PullSupplier.Ref);
Pull_Supplier : in CosEventComm.PullSupplier.Ref);
------------------
-- PullConsumer --
@@ -69,9 +69,8 @@ private
type Proxy_Pull_Consumer_Record;
type Proxy_Pull_Consumer_Access is access all Proxy_Pull_Consumer_Record;
type Object is new PortableServer.Servant_Base with
record
X : Proxy_Pull_Consumer_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Proxy_Pull_Consumer_Access;
end record;
end CosEventChannelAdmin.ProxyPullConsumer.Impl;

View File

@@ -31,11 +31,14 @@
-- --
------------------------------------------------------------------------------
with CosEventComm; use CosEventComm;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PortableServer;
with CosEventComm.PullConsumer;
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CosEventChannelAdmin;
with CosEventChannelAdmin.ProxyPullSupplier.Helper;
pragma Elaborate (CosEventChannelAdmin.ProxyPullSupplier.Helper);
@@ -47,22 +50,24 @@ pragma Warnings (Off, CosEventChannelAdmin.ProxyPullSupplier.Skel);
with CosEventChannelAdmin.ConsumerAdmin.Impl;
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with PolyORB.Tasking.Semaphores; use PolyORB.Tasking.Semaphores;
with PortableServer; use PortableServer;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PolyORB.Log;
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Mutexes;
with PolyORB.Tasking.Semaphores;
with PolyORB.Utils.Chained_Lists;
package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
use PortableServer;
use CosEventComm;
use CosEventChannelAdmin;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Tasking.Mutexes;
use PolyORB.Tasking.Semaphores;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("proxypullsupplier");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
@@ -74,14 +79,32 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
subtype Event_Queue is Event_Queues.List;
type Proxy_Pull_Supplier_Record is
record
This : Object_Ptr;
Peer : PullConsumer.Ref;
Admin : ConsumerAdmin.Impl.Object_Ptr;
Queue : Event_Queue;
Semaphore : Semaphore_Access;
end record;
type Proxy_Pull_Supplier_Record is record
This : Object_Ptr;
Peer : PullConsumer.Ref;
Admin : ConsumerAdmin.Impl.Object_Ptr;
Queue : Event_Queue;
Semaphore : Semaphore_Access;
end record;
---------------------------
-- Ensure_Initialization --
---------------------------
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized
T_Initialized : Boolean := False;
Self_Mutex : Mutex_Access;
procedure Ensure_Initialization is
begin
if not T_Initialized then
Create (Self_Mutex);
T_Initialized := True;
end if;
end Ensure_Initialization;
---------------------------
-- Connect_Pull_Consumer --
@@ -89,25 +112,30 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
procedure Connect_Pull_Consumer
(Self : access Object;
Pull_Consumer : in PullConsumer.Ref) is
Pull_Consumer : in PullConsumer.Ref) is
begin
pragma Debug (O ("connect pull consumer to proxy pull supplier"));
Ensure_Initialization;
Enter (Self_Mutex);
Enter_Critical_Section;
if not PullConsumer.Is_Nil (Self.X.Peer) then
Leave_Critical_Section;
Leave (Self_Mutex);
raise AlreadyConnected;
end if;
Self.X.Peer := Pull_Consumer;
Leave_Critical_Section;
Leave (Self_Mutex);
end Connect_Pull_Consumer;
------------
-- Create --
------------
function Create (Admin : ConsumerAdmin.Impl.Object_Ptr) return Object_Ptr
function Create
(Admin : ConsumerAdmin.Impl.Object_Ptr)
return Object_Ptr
is
Supplier : Object_Ptr;
My_Ref : ProxyPullSupplier.Ref;
@@ -120,7 +148,9 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
Supplier.X.This := Supplier;
Supplier.X.Admin := Admin;
Create (Supplier.X.Semaphore);
Initiate_Servant (Servant (Supplier), My_Ref);
return Supplier;
end Create;
@@ -137,11 +167,14 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
begin
pragma Debug (O ("disconnect proxy pull supplier"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Peer := Self.X.Peer;
Self.X.Peer := Nil_Ref;
Leave (Self_Mutex);
V (Self.X.Semaphore);
Leave_Critical_Section;
if not PullConsumer.Is_Nil (Peer) then
PullConsumer.disconnect_pull_consumer (Peer);
@@ -154,16 +187,17 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any) is
Data : in CORBA.Any) is
begin
pragma Debug (O ("post new data to proxy pull supplier"));
Enter_Critical_Section;
Append (Self.X.Queue, Data);
V (Self.X.Semaphore);
Leave_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Append (Self.X.Queue, Data);
Leave (Self_Mutex);
V (Self.X.Semaphore);
end Post;
----------
@@ -180,18 +214,25 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
pragma Debug
(O ("attempt to pull new data from proxy pull supplier"));
Ensure_Initialization;
P (Self.X.Semaphore);
Enter_Critical_Section;
Enter (Self_Mutex);
if PullConsumer.Is_Nil (Self.X.Peer) then
Leave_Critical_Section;
Leave (Self_Mutex);
raise Disconnected;
end if;
if State (Self.X.Semaphore) >= 0 then
Extract_First (Self.X.Queue, Event);
pragma Debug (O ("succeed to pull data from proxy pull supplier"));
end if;
Leave_Critical_Section;
pragma Debug (O ("succeed to pull new data from proxy pull supplier"));
Leave (Self_Mutex);
-- XXX what if nothing was pulled ?
return Event;
end Pull;
@@ -202,26 +243,29 @@ package body CosEventChannelAdmin.ProxyPullSupplier.Impl is
procedure Try_Pull
(Self : access Object;
Has_Event : out CORBA.Boolean;
Returns : out CORBA.Any) is
Has_Event : out CORBA.Boolean;
Returns : out CORBA.Any) is
begin
pragma Debug (O ("try to pull new data from proxy pull supplier"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
if PullConsumer.Is_Nil (Self.X.Peer) then
Leave_Critical_Section;
Leave (Self_Mutex);
raise Disconnected;
end if;
if State (Self.X.Semaphore) <= 0 then
Has_Event := False;
Has_Event := State (Self.X.Semaphore) > 0;
else
Has_Event := True;
if Has_Event then
Extract_First (Self.X.Queue, Returns);
Leave (Self_Mutex);
P (Self.X.Semaphore);
end if;
Leave_Critical_Section;
end Try_Pull;
end CosEventChannelAdmin.ProxyPullSupplier.Impl;

View File

@@ -37,14 +37,13 @@ with CosEventChannelAdmin.ConsumerAdmin.Impl;
package CosEventChannelAdmin.ProxyPullSupplier.Impl is
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
procedure Connect_Pull_Consumer
(Self : access Object;
Pull_Consumer : in CosEventComm.PullConsumer.Ref);
Pull_Consumer : in CosEventComm.PullConsumer.Ref);
function Pull
(Self : access Object)
@@ -52,8 +51,8 @@ package CosEventChannelAdmin.ProxyPullSupplier.Impl is
procedure Try_Pull
(Self : access Object;
Has_Event : out CORBA.Boolean;
Returns : out CORBA.Any);
Has_Event : out CORBA.Boolean;
Returns : out CORBA.Any);
procedure Disconnect_Pull_Supplier
(Self : access Object);
@@ -64,7 +63,7 @@ package CosEventChannelAdmin.ProxyPullSupplier.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any);
Data : in CORBA.Any);
function Create
(Admin : CosEventChannelAdmin.ConsumerAdmin.Impl.Object_Ptr)
@@ -75,10 +74,8 @@ private
type Proxy_Pull_Supplier_Record;
type Proxy_Pull_Supplier_Access is access all Proxy_Pull_Supplier_Record;
type Object is
new PortableServer.Servant_Base with
record
X : Proxy_Pull_Supplier_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Proxy_Pull_Supplier_Access;
end record;
end CosEventChannelAdmin.ProxyPullSupplier.Impl;

View File

@@ -31,11 +31,16 @@
-- --
------------------------------------------------------------------------------
with CosEventComm; use CosEventComm;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PortableServer;
with CosEventComm;
with CosEventComm.PushSupplier;
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CosEventChannelAdmin;
with CosEventChannelAdmin.ProxyPushConsumer.Helper;
pragma Elaborate (CosEventChannelAdmin.ProxyPushConsumer.Helper);
@@ -47,29 +52,49 @@ pragma Warnings (Off, CosEventChannelAdmin.ProxyPushConsumer.Skel);
with CosEventChannelAdmin.SupplierAdmin.Impl;
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with PortableServer; use PortableServer;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Log;
with PolyORB.Tasking.Mutexes;
package body CosEventChannelAdmin.ProxyPushConsumer.Impl is
use PortableServer;
use CosEventComm;
use CosEventChannelAdmin;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Tasking.Mutexes;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("proxypushconsumer");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
type Proxy_Push_Consumer_Record is
record
This : Object_Ptr;
Peer : PushSupplier.Ref;
Admin : SupplierAdmin.Impl.Object_Ptr;
end record;
type Proxy_Push_Consumer_Record is record
This : Object_Ptr;
Peer : PushSupplier.Ref;
Admin : SupplierAdmin.Impl.Object_Ptr;
end record;
---------------------------
-- Ensure_Initialization --
---------------------------
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized
T_Initialized : Boolean := False;
Self_Mutex : Mutex_Access;
procedure Ensure_Initialization is
begin
if not T_Initialized then
Create (Self_Mutex);
T_Initialized := True;
end if;
end Ensure_Initialization;
---------------------------
-- Connect_Push_Supplier --
@@ -77,24 +102,30 @@ package body CosEventChannelAdmin.ProxyPushConsumer.Impl is
procedure Connect_Push_Supplier
(Self : access Object;
Push_Supplier : in CosEventComm.PushSupplier.Ref) is
Push_Supplier : in CosEventComm.PushSupplier.Ref) is
begin
pragma Debug (O ("connect push supplier to proxy push consumer"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
if not PushSupplier.Is_Nil (Self.X.Peer) then
Leave_Critical_Section;
Leave (Self_Mutex);
raise AlreadyConnected;
end if;
Self.X.Peer := Push_Supplier;
Leave_Critical_Section;
Leave (Self_Mutex);
end Connect_Push_Supplier;
------------
-- Create --
------------
function Create (Admin : SupplierAdmin.Impl.Object_Ptr) return Object_Ptr
function Create
(Admin : SupplierAdmin.Impl.Object_Ptr)
return Object_Ptr
is
Consumer : Object_Ptr;
My_Ref : ProxyPushConsumer.Ref;
@@ -106,7 +137,9 @@ package body CosEventChannelAdmin.ProxyPushConsumer.Impl is
Consumer.X := new Proxy_Push_Consumer_Record;
Consumer.X.This := Consumer;
Consumer.X.Admin := Admin;
Initiate_Servant (Servant (Consumer), My_Ref);
return Consumer;
end Create;
@@ -123,10 +156,12 @@ package body CosEventChannelAdmin.ProxyPushConsumer.Impl is
begin
pragma Debug (O ("disconnect proxy push consumer"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Peer := Self.X.Peer;
Self.X.Peer := Nil_Ref;
Leave_Critical_Section;
Leave (Self_Mutex);
if not PushSupplier.Is_Nil (Peer) then
PushSupplier.disconnect_push_supplier (Peer);
@@ -139,7 +174,7 @@ package body CosEventChannelAdmin.ProxyPushConsumer.Impl is
procedure Push
(Self : access Object;
Data : in CORBA.Any) is
Data : in CORBA.Any) is
begin
pragma Debug
(O ("push new data from proxy push consumer to supplier admin"));

View File

@@ -37,8 +37,7 @@ with CosEventChannelAdmin.SupplierAdmin.Impl;
package CosEventChannelAdmin.ProxyPushConsumer.Impl is
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
@@ -66,10 +65,8 @@ private
type Proxy_Push_Consumer_Record;
type Proxy_Push_Consumer_Access is access all Proxy_Push_Consumer_Record;
type Object is
new PortableServer.Servant_Base with
record
X : Proxy_Push_Consumer_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Proxy_Push_Consumer_Access;
end record;
end CosEventChannelAdmin.ProxyPushConsumer.Impl;

View File

@@ -31,12 +31,13 @@
-- --
------------------------------------------------------------------------------
with CosEventComm; use CosEventComm;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PortableServer;
with CosEventComm.PushConsumer;
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CosEventChannelAdmin.ConsumerAdmin;
with CosEventChannelAdmin.ProxyPushSupplier.Helper;
@@ -47,30 +48,50 @@ with CosEventChannelAdmin.ProxyPushSupplier.Skel;
pragma Elaborate (CosEventChannelAdmin.ProxyPushSupplier.Skel);
pragma Warnings (Off, CosEventChannelAdmin.ProxyPushSupplier.Skel);
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with PortableServer; use PortableServer;
with CORBA.Object;
pragma Warnings (Off, CORBA.Object);
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Mutexes;
with PolyORB.Log;
package body CosEventChannelAdmin.ProxyPushSupplier.Impl is
use PortableServer;
use CosEventComm;
use CosEventChannelAdmin;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Tasking.Mutexes;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("proxypushsupplier");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
type Proxy_Push_Supplier_Record is
record
This : Object_Ptr;
Peer : PushConsumer.Ref;
Admin : ConsumerAdmin.Impl.Object_Ptr;
end record;
type Proxy_Push_Supplier_Record is record
This : Object_Ptr;
Peer : PushConsumer.Ref;
Admin : ConsumerAdmin.Impl.Object_Ptr;
end record;
---------------------------
-- Ensure_Initialization --
---------------------------
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized
T_Initialized : Boolean := False;
Self_Mutex : Mutex_Access;
procedure Ensure_Initialization is
begin
if not T_Initialized then
Create (Self_Mutex);
T_Initialized := True;
end if;
end Ensure_Initialization;
---------------------------
-- Connect_Push_Consumer --
@@ -78,24 +99,31 @@ package body CosEventChannelAdmin.ProxyPushSupplier.Impl is
procedure Connect_Push_Consumer
(Self : access Object;
Push_Consumer : in CosEventComm.PushConsumer.Ref) is
Push_Consumer : in CosEventComm.PushConsumer.Ref) is
begin
pragma Debug (O ("connect push consumer to proxy push supplier"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
if not PushConsumer.Is_Nil (Self.X.Peer) then
Leave_Critical_Section;
Leave (Self_Mutex);
raise AlreadyConnected;
end if;
Self.X.Peer := Push_Consumer;
Leave_Critical_Section;
Leave (Self_Mutex);
end Connect_Push_Consumer;
------------
-- Create --
------------
function Create (Admin : ConsumerAdmin.Impl.Object_Ptr) return Object_Ptr
function Create
(Admin : ConsumerAdmin.Impl.Object_Ptr)
return Object_Ptr
is
Supplier : ProxyPushSupplier.Impl.Object_Ptr;
My_Ref : ProxyPushSupplier.Ref;
@@ -107,7 +135,9 @@ package body CosEventChannelAdmin.ProxyPushSupplier.Impl is
Supplier.X := new Proxy_Push_Supplier_Record;
Supplier.X.This := Supplier;
Supplier.X.Admin := Admin;
Initiate_Servant (Servant (Supplier), My_Ref);
return Supplier;
end Create;
@@ -124,10 +154,12 @@ package body CosEventChannelAdmin.ProxyPushSupplier.Impl is
begin
pragma Debug (O ("disconnect proxy push supplier"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Peer := Self.X.Peer;
Self.X.Peer := Nil_Ref;
Leave_Critical_Section;
Leave (Self_Mutex);
if PushConsumer.Is_Nil (Peer) then
PushConsumer.disconnect_push_consumer (Peer);
@@ -140,15 +172,17 @@ package body CosEventChannelAdmin.ProxyPushSupplier.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any) is
Data : in CORBA.Any) is
begin
pragma Debug
(O ("post new data from proxy push supplier to push consumer"));
begin
PushConsumer.push (Self.X.Peer, Data);
exception when others =>
null;
exception
when others =>
pragma Debug (O ("Got exception in Post"));
raise;
end;
end Post;

View File

@@ -37,8 +37,7 @@ with CosEventChannelAdmin.ConsumerAdmin.Impl;
package CosEventChannelAdmin.ProxyPushSupplier.Impl is
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
@@ -55,7 +54,7 @@ package CosEventChannelAdmin.ProxyPushSupplier.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any);
Data : in CORBA.Any);
function Create
(Admin : CosEventChannelAdmin.ConsumerAdmin.Impl.Object_Ptr)
@@ -66,10 +65,8 @@ private
type Proxy_Push_Supplier_Record;
type Proxy_Push_Supplier_Access is access Proxy_Push_Supplier_Record;
type Object is
new PortableServer.Servant_Base with
record
X : Proxy_Push_Supplier_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Proxy_Push_Supplier_Access;
end record;
end CosEventChannelAdmin.ProxyPushSupplier.Impl;

View File

@@ -31,7 +31,12 @@
-- --
------------------------------------------------------------------------------
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with CORBA.Sequences.Unbounded;
with PortableServer;
with CosEventChannelAdmin.EventChannel.Impl;
@@ -51,23 +56,20 @@ with CosEventChannelAdmin.SupplierAdmin.Skel;
pragma Elaborate (CosEventChannelAdmin.SupplierAdmin.Skel);
pragma Warnings (Off, CosEventChannelAdmin.SupplierAdmin.Skel);
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with CORBA.Sequences.Unbounded;
with PortableServer; use PortableServer;
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Mutexes;
with PolyORB.Log;
package body CosEventChannelAdmin.SupplierAdmin.Impl is
use CosEventChannelAdmin;
use PortableServer;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Tasking.Mutexes;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("consumeradmin");
package L is new PolyORB.Log.Facility_Log ("supplieradmin");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
@@ -77,13 +79,31 @@ package body CosEventChannelAdmin.SupplierAdmin.Impl is
package PushConsumers is
new CORBA.Sequences.Unbounded (ProxyPushConsumer.Impl.Object_Ptr);
type Supplier_Admin_Record is
record
This : Object_Ptr;
Channel : EventChannel.Impl.Object_Ptr;
Pushs : PushConsumers.Sequence;
Pulls : PullConsumers.Sequence;
end record;
type Supplier_Admin_Record is record
This : Object_Ptr;
Channel : EventChannel.Impl.Object_Ptr;
Pushs : PushConsumers.Sequence;
Pulls : PullConsumers.Sequence;
end record;
---------------------------
-- Ensure_Initialization --
---------------------------
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized
T_Initialized : Boolean := False;
Self_Mutex : Mutex_Access;
procedure Ensure_Initialization is
begin
if not T_Initialized then
Create (Self_Mutex);
T_Initialized := True;
end if;
end Ensure_Initialization;
------------
-- Create --
@@ -98,11 +118,13 @@ package body CosEventChannelAdmin.SupplierAdmin.Impl is
begin
pragma Debug (O ("create supplier admin"));
Supplier := new Object;
Supplier.X := new Supplier_Admin_Record;
Supplier := new Object;
Supplier.X := new Supplier_Admin_Record;
Supplier.X.This := Supplier;
Supplier.X.Channel := Channel;
Initiate_Servant (Servant (Supplier), My_Ref);
return Supplier;
end Create;
@@ -120,11 +142,15 @@ package body CosEventChannelAdmin.SupplierAdmin.Impl is
begin
pragma Debug (O ("obtain proxy pull consumer from supplier admin"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Consumer := ProxyPullConsumer.Impl.Create (Self.X.This);
PullConsumers.Append (Self.X.Pulls, Consumer);
Leave_Critical_Section;
Leave (Self_Mutex);
Servant_To_Reference (Servant (Consumer), Its_Ref);
return Its_Ref;
end Obtain_Pull_Consumer;
@@ -142,11 +168,15 @@ package body CosEventChannelAdmin.SupplierAdmin.Impl is
begin
pragma Debug (O ("obtain proxy push consumer from supplier admin"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Consumer := ProxyPushConsumer.Impl.Create (Self.X.This);
PushConsumers.Append (Self.X.Pushs, Consumer);
Leave_Critical_Section;
Leave (Self_Mutex);
Servant_To_Reference (Servant (Consumer), Its_Ref);
return Its_Ref;
end Obtain_Push_Consumer;
@@ -156,7 +186,7 @@ package body CosEventChannelAdmin.SupplierAdmin.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any) is
Data : in CORBA.Any) is
begin
pragma Debug (O ("post new data from supplier admin to channel"));

View File

@@ -38,8 +38,7 @@ with PortableServer;
package CosEventChannelAdmin.SupplierAdmin.Impl is
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
@@ -61,17 +60,15 @@ package CosEventChannelAdmin.SupplierAdmin.Impl is
procedure Post
(Self : access Object;
Data : in CORBA.Any);
Data : in CORBA.Any);
private
type Supplier_Admin_Record;
type Supplier_Admin_Access is access all Supplier_Admin_Record;
type Object is
new PortableServer.Servant_Base with
record
X : Supplier_Admin_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Supplier_Admin_Access;
end record;
end CosEventChannelAdmin.SupplierAdmin.Impl;

View File

@@ -31,6 +31,11 @@
-- --
------------------------------------------------------------------------------
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with PortableServer;
with CosEventComm.PullConsumer.Helper;
pragma Elaborate (CosEventComm.PullConsumer.Helper);
pragma Warnings (Off, CosEventComm.PullConsumer.Helper);
@@ -39,32 +44,50 @@ with CosEventComm.PullConsumer.Skel;
pragma Elaborate (CosEventComm.PullConsumer.Skel);
pragma Warnings (Off, CosEventComm.PullConsumer.Skel);
with CosEventChannelAdmin; use CosEventChannelAdmin;
with CosEventChannelAdmin;
with CosEventChannelAdmin.ProxyPullSupplier;
with PolyORB.CORBA_P.Server_Tools; use PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Soft_Links; use PolyORB.Tasking.Soft_Links;
with CORBA.Impl;
pragma Warnings (Off, CORBA.Impl);
with PortableServer; use PortableServer;
with PolyORB.CORBA_P.Server_Tools;
with PolyORB.Tasking.Mutexes;
with PolyORB.Log;
package body CosEventComm.PullConsumer.Impl is
use CosEventChannelAdmin;
use PortableServer;
use PolyORB.CORBA_P.Server_Tools;
use PolyORB.Tasking.Mutexes;
use PolyORB.Log;
package L is new PolyORB.Log.Facility_Log ("pullconsumer");
procedure O (Message : in Standard.String; Level : Log_Level := Debug)
renames L.Output;
type Pull_Consumer_Record is
record
This : Object_Ptr;
Peer : ProxyPullSupplier.Ref;
end record;
type Pull_Consumer_Record is record
This : Object_Ptr;
Peer : ProxyPullSupplier.Ref;
end record;
---------------------------
-- Ensure_Initialization --
---------------------------
procedure Ensure_Initialization;
pragma Inline (Ensure_Initialization);
-- Ensure that the Mutexes are initialized
T_Initialized : Boolean := False;
Self_Mutex : Mutex_Access;
procedure Ensure_Initialization is
begin
if not T_Initialized then
Create (Self_Mutex);
T_Initialized := True;
end if;
end Ensure_Initialization;
---------------------------------
-- Connect_Proxy_Pull_Supplier --
@@ -79,13 +102,15 @@ package body CosEventComm.PullConsumer.Impl is
begin
pragma Debug (O ("connect proxy pull consumer to pull supplier"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
if not ProxyPullSupplier.Is_Nil (Self.X.Peer) then
Leave_Critical_Section;
Leave (Self_Mutex);
raise AlreadyConnected;
end if;
Self.X.Peer := Proxy;
Leave_Critical_Section;
Leave (Self_Mutex);
Servant_To_Reference (Servant (Self.X.This), My_Ref);
ProxyPullSupplier.connect_pull_consumer (Proxy, My_Ref);
@@ -106,7 +131,9 @@ package body CosEventComm.PullConsumer.Impl is
Consumer := new Object;
Consumer.X := new Pull_Consumer_Record;
Consumer.X.This := Consumer;
Initiate_Servant (Servant (Consumer), My_Ref);
return Consumer;
end Create;
@@ -123,10 +150,12 @@ package body CosEventComm.PullConsumer.Impl is
begin
pragma Debug (O ("disconnect pull consumer"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Peer := Self.X.Peer;
Self.X.Peer := Nil_Ref;
Leave_Critical_Section;
Leave (Self_Mutex);
if not ProxyPullSupplier.Is_Nil (Peer) then
ProxyPullSupplier.disconnect_pull_supplier (Peer);
@@ -137,16 +166,20 @@ package body CosEventComm.PullConsumer.Impl is
-- Pull --
----------
function Pull (Self : access Object) return CORBA.Any
function Pull
(Self : access Object)
return CORBA.Any
is
Peer : ProxyPullSupplier.Ref;
begin
pragma Debug (O ("pull new data from pull consumer"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Peer := Self.X.Peer;
Leave_Critical_Section;
Leave (Self_Mutex);
if ProxyPullSupplier.Is_Nil (Peer) then
raise Disconnected;
@@ -161,17 +194,19 @@ package body CosEventComm.PullConsumer.Impl is
procedure Try_Pull
(Self : access Object;
Done : out CORBA.Boolean;
Returns : out CORBA.Any)
Done : out CORBA.Boolean;
Returns : out CORBA.Any)
is
Peer : ProxyPullSupplier.Ref;
begin
pragma Debug (O ("try to pull new data from pull consumer"));
Enter_Critical_Section;
Ensure_Initialization;
Enter (Self_Mutex);
Peer := Self.X.Peer;
Leave_Critical_Section;
Leave (Self_Mutex);
if ProxyPullSupplier.Is_Nil (Peer) then
raise Disconnected;

View File

@@ -40,8 +40,7 @@ package CosEventComm.PullConsumer.Impl is
-- This implementation is supposed to be application
-- dependent. This is an example used to test the event service.
type Object is
new PortableServer.Servant_Base with private;
type Object is new PortableServer.Servant_Base with private;
type Object_Ptr is access all Object'Class;
@@ -66,8 +65,8 @@ package CosEventComm.PullConsumer.Impl is
procedure Try_Pull
(Self : access Object;
Done : out CORBA.Boolean;
Returns : out CORBA.Any);
Done : out CORBA.Boolean;
Returns : out CORBA.Any);
-- Call by application to try to consume an event
private
@@ -75,10 +74,8 @@ private
type Pull_Consumer_Record;
type Pull_Consumer_Access is access Pull_Consumer_Record;
type Object is
new PortableServer.Servant_Base with
record
X : Pull_Consumer_Access;
end record;
type Object is new PortableServer.Servant_Base with record
X : Pull_Consumer_Access;
end record;
end CosEventComm.PullConsumer.Impl;

Some files were not shown because too many files have changed in this diff Show More