Line data Source code
1 : /**
2 : * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 : * SPDX-License-Identifier: Apache-2.0.
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 0 : void *pred_ctx) {
13 0 :
14 0 : int err_code = 0;
15 0 : while (!err_code && !pred(pred_ctx)) {
16 0 : err_code = aws_condition_variable_wait(condition_variable, mutex);
17 0 : }
18 0 :
19 0 : return err_code;
20 0 : }
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 0 : void *pred_ctx) {
28 0 :
29 0 : int err_code = 0;
30 0 : while (!err_code && !pred(pred_ctx)) {
31 0 : err_code = aws_condition_variable_wait_for(condition_variable, mutex, time_to_wait);
32 0 : }
33 0 :
34 0 : return err_code;
35 0 : }
|