Skip to content

Commit 7653cc4

Browse files
committed
add object oriented interface
1 parent 68dca8d commit 7653cc4

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/stdlib_system.F90

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@ module stdlib_system
5252
!> Store time at the last update
5353
integer(TICKS) :: last_update = 0
5454

55+
contains
56+
57+
!! Check if process is still running
58+
procedure :: is_running => process_is_running
59+
60+
!! Check if process is completed
61+
procedure :: is_completed => process_is_completed
62+
63+
!! Return elapsed time since inception
64+
procedure :: elapsed => process_lifetime
65+
66+
!! Update process state internals
67+
procedure :: update => update_process_state
68+
69+
!! Kill a process
70+
procedure :: kill => process_kill
71+
5572
end type process_type
5673

5774
interface runasync
@@ -142,6 +159,7 @@ module function run_sync_args(args, stdin, want_stdout, want_stderr) result(proc
142159
!> The output process handler.
143160
type(process_type) :: process
144161
end function run_sync_args
162+
145163
end interface run
146164

147165
interface is_running
@@ -264,7 +282,7 @@ end subroutine wait_for_completion
264282
!!
265283
module subroutine update_process_state(process)
266284
!> The process object whose state needs to be updated.
267-
type(process_type), intent(inout) :: process
285+
class(process_type), intent(inout) :: process
268286
end subroutine update_process_state
269287
end interface update
270288

@@ -290,7 +308,7 @@ end subroutine update_process_state
290308
!!
291309
module subroutine process_kill(process, success)
292310
!> The process object to be terminated.
293-
type(process_type), intent(inout) :: process
311+
class(process_type), intent(inout) :: process
294312
!> Boolean flag indicating whether the termination was successful.
295313
logical, intent(out) :: success
296314
end subroutine process_kill

src/stdlib_system_subprocess.F90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ end subroutine wait_for_completion
369369

370370
!> Update a process's state, and save it to the process variable
371371
module subroutine update_process_state(process)
372-
type(process_type), intent(inout) :: process
372+
class(process_type), intent(inout) :: process
373373

374374
real(RTICKS) :: count_rate
375375
integer(TICKS) :: count_max,current_time
@@ -407,7 +407,7 @@ end subroutine update_process_state
407407

408408
! Kill a process
409409
module subroutine process_kill(process, success)
410-
type(process_type), intent(inout) :: process
410+
class(process_type), intent(inout) :: process
411411
! Return a boolean flag for successful operation
412412
logical, intent(out) :: success
413413

@@ -439,7 +439,7 @@ module subroutine process_kill(process, success)
439439
end subroutine process_kill
440440

441441
subroutine save_completed_state(process,delete_files)
442-
type(process_type), intent(inout) :: process
442+
class(process_type), intent(inout) :: process
443443
logical, intent(in) :: delete_files
444444

445445
logical(c_bool) :: running

0 commit comments

Comments
 (0)