As a miner, I want to have helper functions that properly wait on condition variables in mine_blocks_args_t so that I don't have to repeat boiler plate and error prone multithreaded code.
Here's one example of the timed wait code.
*args.should_stop = true;
clock_gettime(CLOCK_REALTIME, &ts);
// One second timeout.
// TODO this timeout code should probably be in a helper function
ts.tv_sec += 1;
pthread_mutex_lock(&args.exit_ready_mutex);
while (!*args.exit_ready) {
int result = pthread_cond_timedwait(
&args.exit_ready_cond, &args.exit_ready_mutex, &ts);
if (ETIMEDOUT == result) {
assert_true(false);
}
}
pthread_mutex_unlock(&args.exit_ready_mutex);
As a miner, I want to have helper functions that properly wait on condition variables in mine_blocks_args_t so that I don't have to repeat boiler plate and error prone multithreaded code.
Here's one example of the timed wait code.