mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Disable thread pool in demo
This commit is contained in:
+19
-19
@@ -1145,29 +1145,29 @@ threading_example :: proc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Thread Pool
|
// { // Thread Pool
|
||||||
fmt.println("\n## Thread Pool")
|
// fmt.println("\n## Thread Pool")
|
||||||
task_proc :: proc(t: ^thread.Task) {
|
// task_proc :: proc(t: ^thread.Task) {
|
||||||
index := t.user_index % len(prefix_table)
|
// index := t.user_index % len(prefix_table)
|
||||||
for iteration in 1..=5 {
|
// for iteration in 1..=5 {
|
||||||
fmt.printf("Worker Task %d is on iteration %d\n", t.user_index, iteration)
|
// fmt.printf("Worker Task %d is on iteration %d\n", t.user_index, iteration)
|
||||||
fmt.printf("`%s`: iteration %d\n", prefix_table[index], iteration)
|
// fmt.printf("`%s`: iteration %d\n", prefix_table[index], iteration)
|
||||||
time.sleep(1 * time.Millisecond)
|
// time.sleep(1 * time.Millisecond)
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
pool: thread.Pool
|
// pool: thread.Pool
|
||||||
thread.pool_init(pool=&pool, thread_count=3)
|
// thread.pool_init(pool=&pool, thread_count=3)
|
||||||
defer thread.pool_destroy(&pool)
|
// defer thread.pool_destroy(&pool)
|
||||||
|
|
||||||
|
|
||||||
for i in 0..<30 {
|
// for i in 0..<30 {
|
||||||
thread.pool_add_task(pool=&pool, procedure=task_proc, data=nil, user_index=i)
|
// thread.pool_add_task(pool=&pool, procedure=task_proc, data=nil, user_index=i)
|
||||||
}
|
// }
|
||||||
|
|
||||||
thread.pool_start(&pool)
|
// thread.pool_start(&pool)
|
||||||
thread.pool_wait_and_process(&pool)
|
// thread.pool_wait_and_process(&pool)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user