Skip to content

Commit c730879

Browse files
reximanion155
andcommitted
Release v1.19.0
Add nob_procs_append_with_flush() Co-authored-by: Mikhaylov Anton <anion155@gmail.com>
1 parent 461513d commit c730879

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

nob.h

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
22
33
This library is the next generation of the [NoBuild](https://github.com/tsoding/nobuild) idea.
44
@@ -394,11 +394,14 @@ typedef struct {
394394
size_t capacity;
395395
} Nob_Procs;
396396

397-
bool nob_procs_wait(Nob_Procs procs);
398-
bool nob_procs_wait_and_reset(Nob_Procs *procs);
399-
400397
// Wait until the process has finished
401398
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);
402405

403406
// A command - the main workhorse of Nob. Nob is all about building commands an running them
404407
typedef struct {
@@ -1102,6 +1105,17 @@ bool nob_proc_wait(Nob_Proc proc)
11021105
#endif
11031106
}
11041107

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+
11051119
bool nob_cmd_run_sync_redirect(Nob_Cmd cmd, Nob_Cmd_Redirect redirect)
11061120
{
11071121
Nob_Proc p = nob_cmd_run_async_redirect(cmd, redirect);
@@ -1883,9 +1897,10 @@ int closedir(DIR *dirp)
18831897
#define fd_open_for_write nob_fd_open_for_write
18841898
#define fd_close nob_fd_close
18851899
#define Procs Nob_Procs
1900+
#define proc_wait nob_proc_wait
18861901
#define procs_wait nob_procs_wait
18871902
#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
18891904
#define Cmd Nob_Cmd
18901905
#define Cmd_Redirect Nob_Cmd_Redirect
18911906
#define cmd_render nob_cmd_render
@@ -1933,6 +1948,7 @@ int closedir(DIR *dirp)
19331948
/*
19341949
Revision history:
19351950
1951+
1.19.0 (2025-03-25) Add nob_procs_append_with_flush() (By @rexim and @anion155)
19361952
1.18.0 (2025-03-24) Add nob_da_foreach() (By @rexim)
19371953
Allow file sizes greater than 2GB to be read on windows (By @satchelfrost and @KillerxDBr)
19381954
Fix nob_fd_open_for_write behaviour on windows so it truncates the opened files (By @twixuss)

0 commit comments

Comments
 (0)