|
1 | | -/* nob - v1.18.0 - Public Domain - https://github.com/tsoding/nob.h |
| 1 | +/* nob - v1.19.0 - Public Domain - https://github.com/tsoding/nob.h |
2 | 2 |
|
3 | 3 | This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea. |
4 | 4 |
|
@@ -394,11 +394,14 @@ typedef struct { |
394 | 394 | size_t capacity; |
395 | 395 | } Nob_Procs; |
396 | 396 |
|
397 | | -bool nob_procs_wait(Nob_Procs procs); |
398 | | -bool nob_procs_wait_and_reset(Nob_Procs *procs); |
399 | | - |
400 | 397 | // Wait until the process has finished |
401 | 398 | bool nob_proc_wait(Nob_Proc proc); |
| 399 | +// Wait until all the processes have finished |
| 400 | +bool nob_procs_wait(Nob_Procs procs); |
| 401 | +// Wait until all the processes have finished and empty the procs array |
| 402 | +bool nob_procs_wait_and_reset(Nob_Procs *procs); |
| 403 | +// Append a new process to procs array and if procs.count reaches max_procs_count call nob_procs_wait_and_reset() on it |
| 404 | +bool nob_procs_append_with_flush(Nob_Procs *procs, Nob_Proc proc, size_t max_procs_count); |
402 | 405 |
|
403 | 406 | // A command - the main workhorse of Nob. Nob is all about building commands an running them |
404 | 407 | typedef struct { |
@@ -1102,6 +1105,17 @@ bool nob_proc_wait(Nob_Proc proc) |
1102 | 1105 | #endif |
1103 | 1106 | } |
1104 | 1107 |
|
| 1108 | +bool nob_procs_append_with_flush(Nob_Procs *procs, Nob_Proc proc, size_t max_procs_count) |
| 1109 | +{ |
| 1110 | + nob_da_append(procs, proc); |
| 1111 | + |
| 1112 | + if (procs->count >= max_procs_count) { |
| 1113 | + if (!nob_procs_wait_and_reset(procs)) return false; |
| 1114 | + } |
| 1115 | + |
| 1116 | + return true; |
| 1117 | +} |
| 1118 | + |
1105 | 1119 | bool nob_cmd_run_sync_redirect(Nob_Cmd cmd, Nob_Cmd_Redirect redirect) |
1106 | 1120 | { |
1107 | 1121 | Nob_Proc p = nob_cmd_run_async_redirect(cmd, redirect); |
@@ -1883,9 +1897,10 @@ int closedir(DIR *dirp) |
1883 | 1897 | #define fd_open_for_write nob_fd_open_for_write |
1884 | 1898 | #define fd_close nob_fd_close |
1885 | 1899 | #define Procs Nob_Procs |
| 1900 | + #define proc_wait nob_proc_wait |
1886 | 1901 | #define procs_wait nob_procs_wait |
1887 | 1902 | #define procs_wait_and_reset nob_procs_wait_and_reset |
1888 | | - #define proc_wait nob_proc_wait |
| 1903 | + #define procs_append_with_flush nob_procs_append_with_flush |
1889 | 1904 | #define Cmd Nob_Cmd |
1890 | 1905 | #define Cmd_Redirect Nob_Cmd_Redirect |
1891 | 1906 | #define cmd_render nob_cmd_render |
@@ -1933,6 +1948,7 @@ int closedir(DIR *dirp) |
1933 | 1948 | /* |
1934 | 1949 | Revision history: |
1935 | 1950 |
|
| 1951 | + 1.19.0 (2025-03-25) Add nob_procs_append_with_flush() (By @rexim and @anion155) |
1936 | 1952 | 1.18.0 (2025-03-24) Add nob_da_foreach() (By @rexim) |
1937 | 1953 | Allow file sizes greater than 2GB to be read on windows (By @satchelfrost and @KillerxDBr) |
1938 | 1954 | Fix nob_fd_open_for_write behaviour on windows so it truncates the opened files (By @twixuss) |
|
0 commit comments