mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
thread broadcast
This commit is contained in:
@@ -245,3 +245,17 @@ tp_divide_work(Arena *arena, U64 item_count, U32 worker_count)
|
||||
|
||||
return range_arr;
|
||||
}
|
||||
|
||||
internal void *
|
||||
tp_broadcast_(TP_Context *tp, U64 task_id, void *ptr)
|
||||
{
|
||||
if (task_id == 0) {
|
||||
tp->broadcast = ptr;
|
||||
}
|
||||
barrier_wait(tp->barrier);
|
||||
|
||||
void *result = tp->broadcast;
|
||||
barrier_wait(tp->barrier);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef struct TP_Context
|
||||
Semaphore task_semaphore;
|
||||
Semaphore main_semaphore;
|
||||
Barrier barrier;
|
||||
void *broadcast;
|
||||
|
||||
U32 worker_count;
|
||||
TP_Worker *worker_arr;
|
||||
@@ -54,4 +55,5 @@ internal void tp_temp_end(TP_Temp temp);
|
||||
#define tp_for_parallel_prof(pool, arena, task_count, task_func, task_data, zone_name) ProfBegin(zone_name); tp_for_parallel(pool, arena, task_count, task_func, task_data); ProfEnd();
|
||||
internal void tp_for_parallel(TP_Context *pool, TP_Arena *arena, U64 task_count, TP_TaskFunc *task_func, void *task_data);
|
||||
internal Rng1U64 * tp_divide_work(Arena *arena, U64 item_count, U32 worker_count);
|
||||
#define tp_broadcast(p) *(p) = tp_broadcast_(tp, task_id, *(p))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user