File tree Expand file tree Collapse file tree 2 files changed +53
-4
lines changed Expand file tree Collapse file tree 2 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -315,3 +315,35 @@ else
315
315
print *, "Failed to kill the process."
316
316
end if
317
317
```
318
+
319
+ ## ` sleep ` - Pause execution for a specified time in milliseconds
320
+
321
+ ### Status
322
+
323
+ Experimental
324
+
325
+ ### Description
326
+
327
+ The ` sleep ` interface pauses the execution of a program for a specified duration, given in milliseconds.
328
+ This routine acts as a cross-platform wrapper, abstracting the underlying platform-specific sleep implementations.
329
+ It ensures that the requested sleep duration is honored on both Windows and Unix-like systems.
330
+
331
+ ### Syntax
332
+
333
+ ` call ` [[ stdlib_system(module): sleep (subroutine)]] ` (millisec) `
334
+
335
+ ### Arguments
336
+
337
+ ` millisec ` : Shall be an ` integer ` representing the number of milliseconds to sleep. This is an ` intent(in) ` argument.
338
+
339
+ ### Example
340
+
341
+ ``` fortran
342
+ ! Example usage of sleep
343
+ print *, "Starting sleep..."
344
+
345
+ ! Sleep for 500 milliseconds
346
+ call sleep(500)
347
+
348
+ print *, "Finished sleeping!"
349
+ ```
Original file line number Diff line number Diff line change @@ -256,14 +256,31 @@ module subroutine process_kill(process, success)
256
256
end subroutine process_kill
257
257
end interface kill
258
258
259
-
260
- ! ! version: experimental
261
- ! !
262
259
interface sleep
260
+ ! ! version: experimental
261
+ ! !
262
+ ! ! Pauses execution for a specified time in milliseconds.
263
+ ! ! ([Specification](../page/specs/stdlib_system.html#sleep-pause-execution-for-a-specified-time))
264
+ ! !
265
+ ! ! ### Summary
266
+ ! ! Pauses code execution for a specified number of milliseconds. This routine is a cross-platform
267
+ ! ! wrapper around platform-specific sleep functions, providing consistent behavior on different operating systems.
268
+ ! !
269
+ ! ! ### Description
270
+ ! !
271
+ ! ! This interface allows the user to pause the execution of a program for a specified duration, expressed in
272
+ ! ! milliseconds. It provides a cross-platform wrapper around native sleep functions, ensuring that the program
273
+ ! ! will sleep for the requested amount of time on different systems (e.g., using `Sleep` on Windows or `nanosleep`
274
+ ! ! on Unix-like systems).
275
+ ! !
276
+ ! ! @note The precision of the sleep may vary depending on the system and platform.
277
+ ! !
263
278
module subroutine sleep (millisec )
279
+ ! > The number of milliseconds to pause execution for.
264
280
integer , intent (in ) :: millisec
265
281
end subroutine sleep
266
- end interface sleep
282
+ end interface sleep
283
+
267
284
268
285
! ! version: experimental
269
286
! !
You can’t perform that action at this time.
0 commit comments