diff --git a/src/fs/walk_test.mbt b/src/fs/walk_test.mbt index f09517a..e771ecf 100644 --- a/src/fs/walk_test.mbt +++ b/src/fs/walk_test.mbt @@ -30,11 +30,12 @@ async test "walk sequential" { async test "walk parallel" { @async.sleep(300) let log = StringBuilder::new() + let mut i = 0 @fs.walk("test_directory", max_concurrency=2, fn(path, _) { + i = i + 1 log.write_string("handling \{path}\n") - @async.sleep(300) + @async.sleep(if i == 1 { 200 } else { 300 }) log.write_string("finished handling \{path}\n") - @async.sleep(100) }) inspect( log.to_string(), @@ -42,8 +43,8 @@ async test "walk parallel" { #|handling test_directory #|handling test_directory/inner1 #|finished handling test_directory - #|finished handling test_directory/inner1 #|handling test_directory/inner1/inner2 + #|finished handling test_directory/inner1 #|finished handling test_directory/inner1/inner2 #| ), diff --git a/src/internal/event_loop/thread_pool.c b/src/internal/event_loop/thread_pool.c index 68c3c0a..2543960 100644 --- a/src/internal/event_loop/thread_pool.c +++ b/src/internal/event_loop/thread_pool.c @@ -120,13 +120,14 @@ void *worker_loop(void *data) { #endif while (job) { + int job_id = job->job_id; job->ret = 0; job->err = 0; job->worker(job); self->waiting = 1; - write(pool.notify_send, &(job->job_id), sizeof(int)); + write(pool.notify_send, &job_id, sizeof(int)); #ifdef WAKEUP_METHOD_SIGNAL sigwait(&pool.wakeup_signal, &sig);