Skip to content

Commit c907b09

Browse files
committed
API for applications without event loop.
1 parent 725a42d commit c907b09

File tree

3 files changed

+162
-0
lines changed

3 files changed

+162
-0
lines changed

source/spawn/spawn-processes.ads

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,48 @@ package Spawn.Processes is
178178
Data : out Ada.Streams.Stream_Element_Array;
179179
Last : out Ada.Streams.Stream_Element_Offset);
180180

181+
function Wait_For_Started
182+
(Self : in out Process'Class;
183+
Timeout : Duration := Duration'Last) return Boolean;
184+
-- Block until process has started or until Timeout have passed. Return
185+
-- True when process has been started successfully.
186+
--
187+
-- Started subprogram of the listener is called before exit from this
188+
-- subprogram.
189+
190+
function Wait_For_Finished
191+
(Self : in out Process'Class;
192+
Timeout : Duration := Duration'Last) return Boolean;
193+
-- Block until process has been finished ot until Timeout have passed.
194+
-- Return True when process has finished.
195+
--
196+
-- Finished subprogram of the listener is called before exit from this
197+
-- subprogram.
198+
199+
function Wait_For_Standard_Input_Available
200+
(Self : in out Process'Class;
201+
Timeout : Duration := Duration'Last) return Boolean;
202+
-- Block until standard input is available for write.
203+
--
204+
-- Standard_Input_Available subprogram of the listener is called before
205+
-- exit from this subprogram.
206+
207+
function Wait_For_Standard_Output_Available
208+
(Self : in out Process'Class;
209+
Timeout : Duration := Duration'Last) return Boolean;
210+
-- Block until standard output has data available for read.
211+
--
212+
-- Standard_Output_Available subprogram of the listener is called before
213+
-- exit from this subprogram.
214+
215+
function Wait_For_Standard_Error_Available
216+
(Self : in out Process'Class;
217+
Timeout : Duration := Duration'Last) return Boolean;
218+
-- Block until standard error has data available for read.
219+
--
220+
-- Standard_Error_Available subprogram of the listener is called before
221+
-- exit from this subprogram.
222+
181223
private
182224

183225
use all type Internal.Pipe_Kinds;

source/spawn/spawn-processes__posix.adb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,66 @@ package body Spawn.Processes is
312312
pragma Assert (Code = 0);
313313
end Terminate_Process;
314314

315+
-----------------------
316+
-- Wait_For_Finished --
317+
-----------------------
318+
319+
function Wait_For_Finished
320+
(Self : in out Process'Class;
321+
Timeout : Duration := Duration'Last) return Boolean is
322+
begin
323+
raise Program_Error;
324+
return False;
325+
end Wait_For_Finished;
326+
327+
---------------------------------------
328+
-- Wait_For_Standard_Error_Available --
329+
---------------------------------------
330+
331+
function Wait_For_Standard_Error_Available
332+
(Self : in out Process'Class;
333+
Timeout : Duration := Duration'Last) return Boolean is
334+
begin
335+
raise Program_Error;
336+
return False;
337+
end Wait_For_Standard_Error_Available;
338+
339+
---------------------------------------
340+
-- Wait_For_Standard_Input_Available --
341+
---------------------------------------
342+
343+
function Wait_For_Standard_Input_Available
344+
(Self : in out Process'Class;
345+
Timeout : Duration := Duration'Last) return Boolean is
346+
begin
347+
raise Program_Error;
348+
return False;
349+
end Wait_For_Standard_Input_Available;
350+
351+
----------------------------------------
352+
-- Wait_For_Standard_Output_Available --
353+
----------------------------------------
354+
355+
function Wait_For_Standard_Output_Available
356+
(Self : in out Process'Class;
357+
Timeout : Duration := Duration'Last) return Boolean is
358+
begin
359+
raise Program_Error;
360+
return False;
361+
end Wait_For_Standard_Output_Available;
362+
363+
----------------------
364+
-- Wait_For_Started --
365+
----------------------
366+
367+
function Wait_For_Started
368+
(Self : in out Process'Class;
369+
Timeout : Duration := Duration'Last) return Boolean is
370+
begin
371+
raise Program_Error;
372+
return False;
373+
end Wait_For_Started;
374+
315375
-----------------------
316376
-- Working_Directory --
317377
-----------------------

source/spawn/spawn-processes__windows.adb

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,66 @@ package body Spawn.Processes is
263263
Windows.Do_Terminate_Process (Self);
264264
end Terminate_Process;
265265

266+
-----------------------
267+
-- Wait_For_Finished --
268+
-----------------------
269+
270+
function Wait_For_Finished
271+
(Self : in out Process'Class;
272+
Timeout : Duration := Duration'Last) return Boolean is
273+
begin
274+
raise Program_Error;
275+
return False;
276+
end Wait_For_Finished;
277+
278+
---------------------------------------
279+
-- Wait_For_Standard_Error_Available --
280+
---------------------------------------
281+
282+
function Wait_For_Standard_Error_Available
283+
(Self : in out Process'Class;
284+
Timeout : Duration := Duration'Last) return Boolean is
285+
begin
286+
raise Program_Error;
287+
return False;
288+
end Wait_For_Standard_Error_Available;
289+
290+
---------------------------------------
291+
-- Wait_For_Standard_Input_Available --
292+
---------------------------------------
293+
294+
function Wait_For_Standard_Input_Available
295+
(Self : in out Process'Class;
296+
Timeout : Duration := Duration'Last) return Boolean is
297+
begin
298+
raise Program_Error;
299+
return False;
300+
end Wait_For_Standard_Input_Available;
301+
302+
----------------------------------------
303+
-- Wait_For_Standard_Output_Available --
304+
----------------------------------------
305+
306+
function Wait_For_Standard_Output_Available
307+
(Self : in out Process'Class;
308+
Timeout : Duration := Duration'Last) return Boolean is
309+
begin
310+
raise Program_Error;
311+
return False;
312+
end Wait_For_Standard_Output_Available;
313+
314+
----------------------
315+
-- Wait_For_Started --
316+
----------------------
317+
318+
function Wait_For_Started
319+
(Self : in out Process'Class;
320+
Timeout : Duration := Duration'Last) return Boolean is
321+
begin
322+
raise Program_Error;
323+
return False;
324+
end Wait_For_Started;
325+
266326
-----------------------
267327
-- Working_Directory --
268328
-----------------------

0 commit comments

Comments
 (0)