Skip to content

Commit

Permalink
[sledge] Allow timeout to be passed to thread_join
Browse files Browse the repository at this point in the history
Differential Revision: D32511364

fbshipit-source-id: b3783e6b2
  • Loading branch information
jberdine authored and facebook-github-bot committed Nov 19, 2021
1 parent 7f2f06c commit a4f3303
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions sledge/test/analyze/cqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ main(void)
thread_resume(produce_threads[i]);
}
for (uint32_t i = 0; i < NUM_PRODUCE_THREADS; i++) {
status = thread_join(produce_threads[i], &thread_ret);
status = thread_join(produce_threads[i], &thread_ret, TIME_INFINITE);
assert(OK == status && "Failed to join thread");
total_produce += thread_ret;
if (thread_ret != 0) {
Expand All @@ -207,7 +207,7 @@ main(void)
thread_resume(consume_threads[i]);
}
for (uint32_t i = 0; i < NUM_CONSUME_THREADS; i++) {
status = thread_join(consume_threads[i], &thread_ret);
status = thread_join(consume_threads[i], &thread_ret, TIME_INFINITE);
assert(OK == status && "Failed to join thread");
total_consume += thread_ret;
if (thread_ret != 0) {
Expand Down
2 changes: 1 addition & 1 deletion sledge/test/analyze/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ main()
error_t err = thread_create(&child, "child", &child_routine, NULL);
thread_resume(child);
int ret_code;
err = thread_join(child, &ret_code);
err = thread_join(child, &ret_code, TIME_INFINITE);
count += ret_code;
return count;
}
4 changes: 3 additions & 1 deletion sledge/test/analyze/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ thread_resume(thread_t* thread)
return true;
}

#define TIME_INFINITE UINT64_MAX

error_t
thread_join(thread_t* thread, int* ret_code)
thread_join(thread_t* thread, int* ret_code, uint64_t timeout)
{
*ret_code = sledge_thread_join(*thread);
return OK;
Expand Down
4 changes: 2 additions & 2 deletions sledge/test/analyze/treiber_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ main(void)
thread_resume(push_threads[i]);
}
for (int i = 0; i < NUM_PUSH_THREADS; i++) {
status = thread_join(push_threads[i], &thread_ret);
status = thread_join(push_threads[i], &thread_ret, TIME_INFINITE);
assert(OK == status && "Thread joined successfully");
total_push += thread_ret;
if (thread_ret != 0) {
Expand All @@ -174,7 +174,7 @@ main(void)
thread_resume(pop_threads[i]);
}
for (int i = 0; i < NUM_POP_THREADS; i++) {
status = thread_join(pop_threads[i], &thread_ret);
status = thread_join(pop_threads[i], &thread_ret, TIME_INFINITE);
assert(OK == status && "Thread joined successfully");
total_pop += thread_ret;
if (thread_ret != 0) {
Expand Down

0 comments on commit a4f3303

Please sign in to comment.