Add worker_sync_p function.
This commit is contained in:
1 parent
e59308a9a3
commit
6cccbfc73a
2 files changed
+16
-4
No files matched your search
@@ -4190,6 +4190,11 @@ If no worker is available, the work order 'func(data)' will be handled
|
|||||||
by the caller. Otherwise the work order 'func(data)' will be handled
|
by the caller. Otherwise the work order 'func(data)' will be handled
|
||||||
by an asynchronous worker.
|
by an asynchronous worker.
|
||||||
|
|
||||||
|
#### bool worker\_sync\_p(worker\_block\_t syncBlock)
|
||||||
|
|
||||||
|
Test if all work orders registered to this synchronization point are
|
||||||
|
finished (true) or not (false).
|
||||||
|
|
||||||
#### void worker\_sync(worker\_block\_t syncBlock)
|
#### void worker\_sync(worker\_block\_t syncBlock)
|
||||||
|
|
||||||
Wait for all work orders registered to this synchronization point to be
|
Wait for all work orders registered to this synchronization point to be
|
||||||
|
|||||||
+11
-4
@@ -309,15 +309,22 @@ worker_spawn_function(worker_t g, worker_sync_t block, std::function<void(void *
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Test if all work orders are finished */
|
||||||
|
static inline bool
|
||||||
|
worker_sync_p(worker_sync_t block)
|
||||||
|
{
|
||||||
|
/* If the number of spawns is greated than the number
|
||||||
|
of terminated spawns, some spawns are still working.
|
||||||
|
So wait for terminaison */
|
||||||
|
return (atomic_load(&block->num_spawn) == atomic_load (&block->num_terminated_spawn));
|
||||||
|
}
|
||||||
|
|
||||||
/* Wait for all work orders to be finished */
|
/* Wait for all work orders to be finished */
|
||||||
static inline void
|
static inline void
|
||||||
worker_sync(worker_sync_t block)
|
worker_sync(worker_sync_t block)
|
||||||
{
|
{
|
||||||
//printf ("Waiting for thread terminasion.\n");
|
//printf ("Waiting for thread terminasion.\n");
|
||||||
/* If the number of spawns is greated than the number
|
while (!worker_sync_p(block)) ;
|
||||||
of terminated spawns, some spawns are still working.
|
|
||||||
So wait for terminaison */
|
|
||||||
while (atomic_load(&block->num_spawn) != atomic_load (&block->num_terminated_spawn));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush any work order in the queue if some remains.*/
|
/* Flush any work order in the queue if some remains.*/
|
||||||
|
|||||||
Reference in new issue
Block a user