lace.event_connector.destruct: Wait til all connectors are idle before exiting.
This commit is contained in:
@@ -134,37 +134,48 @@ is
|
|||||||
is
|
is
|
||||||
use ada.Text_IO;
|
use ada.Text_IO;
|
||||||
|
|
||||||
the_Connectors : aliased safe_Connectors;
|
all_Connectors : connector_Vector;
|
||||||
|
idle_Connectors : aliased safe_Connectors;
|
||||||
the_Connections : safe_Connections_view;
|
the_Connections : safe_Connections_view;
|
||||||
new_Connections : connection_Vector;
|
new_Connections : connection_Vector;
|
||||||
Done : Boolean := False;
|
Done : Boolean := False;
|
||||||
|
|
||||||
|
|
||||||
|
function all_Connectors_are_idle return Boolean
|
||||||
|
is
|
||||||
|
Result : Boolean := True;
|
||||||
|
begin
|
||||||
|
for Each of all_Connectors
|
||||||
|
loop
|
||||||
|
if not Each'Callable
|
||||||
|
then
|
||||||
|
Result := False;
|
||||||
|
exit;
|
||||||
|
end if;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
end all_Connectors_are_idle;
|
||||||
|
|
||||||
|
|
||||||
procedure shutdown
|
procedure shutdown
|
||||||
is
|
is
|
||||||
procedure free is new ada.unchecked_Deallocation (Connector,
|
procedure free is new ada.unchecked_Deallocation (Connector,
|
||||||
Connector_view);
|
Connector_view);
|
||||||
the_Connector : Connector_view;
|
the_Connector : Connector_view;
|
||||||
begin
|
begin
|
||||||
|
for Each of all_Connectors
|
||||||
loop
|
loop
|
||||||
the_Connectors.get (the_Connector);
|
the_Connector := Each;
|
||||||
exit when the_Connector = null;
|
|
||||||
|
|
||||||
free (the_Connector);
|
free (the_Connector);
|
||||||
end loop;
|
end loop;
|
||||||
end shutdown;
|
end shutdown;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
ada.text_io.put_Line ("KKK0");
|
|
||||||
|
|
||||||
accept start (Connections : in safe_Connections_view)
|
accept start (Connections : in safe_Connections_view)
|
||||||
do
|
do
|
||||||
ada.text_io.put_Line ("KKK2");
|
|
||||||
|
|
||||||
the_Connections := Connections;
|
the_Connections := Connections;
|
||||||
ada.text_io.put_Line ("KKK3");
|
|
||||||
|
|
||||||
end start;
|
end start;
|
||||||
|
|
||||||
|
|
||||||
@@ -191,16 +202,17 @@ is
|
|||||||
use lace.Text;
|
use lace.Text;
|
||||||
the_Connector : Connector_view;
|
the_Connector : Connector_view;
|
||||||
begin
|
begin
|
||||||
the_Connectors.get (the_Connector);
|
idle_Connectors.get (the_Connector);
|
||||||
|
|
||||||
if the_Connector = null
|
if the_Connector = null
|
||||||
then
|
then
|
||||||
the_Connector := new Connector;
|
the_Connector := new Connector;
|
||||||
|
all_Connectors.append (the_Connector);
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
the_Connector.connect (Self => the_Connector,
|
the_Connector.connect (Self => the_Connector,
|
||||||
the_Connection => each_Connection,
|
the_Connection => each_Connection,
|
||||||
Connectors => the_Connectors'unchecked_Access);
|
Connectors => idle_Connectors'unchecked_Access);
|
||||||
exception
|
exception
|
||||||
when E : others =>
|
when E : others =>
|
||||||
new_Line;
|
new_Line;
|
||||||
@@ -221,6 +233,13 @@ is
|
|||||||
delay 0.001; -- Keep task from churning when idle.
|
delay 0.001; -- Keep task from churning when idle.
|
||||||
end loop;
|
end loop;
|
||||||
|
|
||||||
|
|
||||||
|
while not all_Connectors_are_idle
|
||||||
|
loop
|
||||||
|
delay 0.001;
|
||||||
|
end loop;
|
||||||
|
|
||||||
|
|
||||||
shutdown;
|
shutdown;
|
||||||
|
|
||||||
exception
|
exception
|
||||||
@@ -375,4 +394,15 @@ is
|
|||||||
end disconnect;
|
end disconnect;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- function is_Busy (Self : in Item) return Boolean
|
||||||
|
-- is
|
||||||
|
-- begin
|
||||||
|
-- return false;
|
||||||
|
-- -- return not ( Self.Connections.is_Empty
|
||||||
|
-- -- and Self.Delegator .active_Count = 0);
|
||||||
|
-- end is_Busy;
|
||||||
|
|
||||||
|
|
||||||
end lace.event_Connector;
|
end lace.event_Connector;
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ with
|
|||||||
|
|
||||||
|
|
||||||
package lace.event_Connector
|
package lace.event_Connector
|
||||||
|
--
|
||||||
|
--
|
||||||
|
--
|
||||||
is
|
is
|
||||||
|
|
||||||
type Item is tagged limited private;
|
type Item is tagged limited private;
|
||||||
@@ -31,6 +34,9 @@ is
|
|||||||
to_Event_Kind : in Event.Kind;
|
to_Event_Kind : in Event.Kind;
|
||||||
subject_Name : in String);
|
subject_Name : in String);
|
||||||
|
|
||||||
|
-- function is_Busy (Self : in Item) return Boolean;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
@@ -79,7 +85,7 @@ private
|
|||||||
procedure add (new_Connection : in Connection);
|
procedure add (new_Connection : in Connection);
|
||||||
procedure get (the_Connections : out connection_Vector);
|
procedure get (the_Connections : out connection_Vector);
|
||||||
|
|
||||||
function is_Empty return Boolean;
|
function is_Empty return Boolean;
|
||||||
|
|
||||||
private
|
private
|
||||||
all_Connections : connection_Vector;
|
all_Connections : connection_Vector;
|
||||||
|
|||||||
Reference in New Issue
Block a user