| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#include <aws/common/condition_variable.h> |
| 7 |
|
| 8 |
int aws_condition_variable_wait_pred( |
| 9 |
struct aws_condition_variable *condition_variable, |
| 10 |
struct aws_mutex *mutex, |
| 11 |
aws_condition_predicate_fn *pred, |
| 12 |
void *pred_ctx) { |
| 13 |
|
| 14 |
int err_code = 0; |
| 15 |
while (!err_code && !pred(pred_ctx)) { |
| 16 |
err_code = aws_condition_variable_wait(condition_variable, mutex); |
| 17 |
} |
| 18 |
|
| 19 |
return err_code; |
| 20 |
} |
| 21 |
|
| 22 |
int aws_condition_variable_wait_for_pred( |
| 23 |
struct aws_condition_variable *condition_variable, |
| 24 |
struct aws_mutex *mutex, |
| 25 |
int64_t time_to_wait, |
| 26 |
aws_condition_predicate_fn *pred, |
| 27 |
void *pred_ctx) { |
| 28 |
|
| 29 |
int err_code = 0; |
| 30 |
while (!err_code && !pred(pred_ctx)) { |
| 31 |
err_code = aws_condition_variable_wait_for(condition_variable, mutex, time_to_wait); |
| 32 |
} |
| 33 |
|
| 34 |
return err_code; |
| 35 |
} |