Skip to content

API for applications without event loop. #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions source/spawn/spawn-processes.ads
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,48 @@ package Spawn.Processes is
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);

function Wait_For_Started
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean;
-- Block until process has started or until Timeout have passed. Return
-- True when process has been started successfully.
--
-- Started subprogram of the listener is called before exit from this
-- subprogram.

function Wait_For_Finished
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean;
-- Block until process has been finished ot until Timeout have passed.
-- Return True when process has finished.
--
-- Finished subprogram of the listener is called before exit from this
-- subprogram.

function Wait_For_Standard_Input_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean;
-- Block until standard input is available for write.
--
-- Standard_Input_Available subprogram of the listener is called before
-- exit from this subprogram.

function Wait_For_Standard_Output_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean;
-- Block until standard output has data available for read.
--
-- Standard_Output_Available subprogram of the listener is called before
-- exit from this subprogram.

function Wait_For_Standard_Error_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean;
-- Block until standard error has data available for read.
--
-- Standard_Error_Available subprogram of the listener is called before
-- exit from this subprogram.

private

use all type Internal.Pipe_Kinds;
Expand Down
60 changes: 60 additions & 0 deletions source/spawn/spawn-processes__glib.adb
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,66 @@ package body Spawn.Processes is
pragma Assert (Code = 0);
end Terminate_Process;

-----------------------
-- Wait_For_Finished --
-----------------------

function Wait_For_Finished
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Finished;

---------------------------------------
-- Wait_For_Standard_Error_Available --
---------------------------------------

function Wait_For_Standard_Error_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Error_Available;

---------------------------------------
-- Wait_For_Standard_Input_Available --
---------------------------------------

function Wait_For_Standard_Input_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Input_Available;

----------------------------------------
-- Wait_For_Standard_Output_Available --
----------------------------------------

function Wait_For_Standard_Output_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Output_Available;

----------------------
-- Wait_For_Started --
----------------------

function Wait_For_Started
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Started;

-----------------------
-- Working_Directory --
-----------------------
Expand Down
60 changes: 60 additions & 0 deletions source/spawn/spawn-processes__glib_windows.adb
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,66 @@ package body Spawn.Processes is
Windows.Do_Terminate_Process (Self);
end Terminate_Process;

-----------------------
-- Wait_For_Finished --
-----------------------

function Wait_For_Finished
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Finished;

---------------------------------------
-- Wait_For_Standard_Error_Available --
---------------------------------------

function Wait_For_Standard_Error_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Error_Available;

---------------------------------------
-- Wait_For_Standard_Input_Available --
---------------------------------------

function Wait_For_Standard_Input_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Input_Available;

----------------------------------------
-- Wait_For_Standard_Output_Available --
----------------------------------------

function Wait_For_Standard_Output_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Output_Available;

----------------------
-- Wait_For_Started --
----------------------

function Wait_For_Started
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Started;

-----------------------
-- Working_Directory --
-----------------------
Expand Down
60 changes: 60 additions & 0 deletions source/spawn/spawn-processes__posix.adb
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,66 @@ package body Spawn.Processes is
pragma Assert (Code = 0);
end Terminate_Process;

-----------------------
-- Wait_For_Finished --
-----------------------

function Wait_For_Finished
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Finished;

---------------------------------------
-- Wait_For_Standard_Error_Available --
---------------------------------------

function Wait_For_Standard_Error_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Error_Available;

---------------------------------------
-- Wait_For_Standard_Input_Available --
---------------------------------------

function Wait_For_Standard_Input_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Input_Available;

----------------------------------------
-- Wait_For_Standard_Output_Available --
----------------------------------------

function Wait_For_Standard_Output_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Output_Available;

----------------------
-- Wait_For_Started --
----------------------

function Wait_For_Started
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Started;

-----------------------
-- Working_Directory --
-----------------------
Expand Down
60 changes: 60 additions & 0 deletions source/spawn/spawn-processes__windows.adb
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,66 @@ package body Spawn.Processes is
Windows.Do_Terminate_Process (Self);
end Terminate_Process;

-----------------------
-- Wait_For_Finished --
-----------------------

function Wait_For_Finished
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Finished;

---------------------------------------
-- Wait_For_Standard_Error_Available --
---------------------------------------

function Wait_For_Standard_Error_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Error_Available;

---------------------------------------
-- Wait_For_Standard_Input_Available --
---------------------------------------

function Wait_For_Standard_Input_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Input_Available;

----------------------------------------
-- Wait_For_Standard_Output_Available --
----------------------------------------

function Wait_For_Standard_Output_Available
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Standard_Output_Available;

----------------------
-- Wait_For_Started --
----------------------

function Wait_For_Started
(Self : in out Process'Class;
Timeout : Duration := Duration'Last) return Boolean is
begin
raise Program_Error;
return False;
end Wait_For_Started;

-----------------------
-- Working_Directory --
-----------------------
Expand Down