9 |
|
|
10 |
// ConditionChecker |
// ConditionChecker |
11 |
|
|
12 |
ConditionTest::ConditionChecker::ConditionChecker(bool waitFor) : Thread(false, 0, -4) { |
ConditionTest::ConditionChecker::ConditionChecker(bool waitFor) : Thread(false, false, 0, -4) { |
13 |
resource = 0; |
resource = 0; |
14 |
this->waitFor = waitFor; |
this->waitFor = waitFor; |
15 |
} |
} |
17 |
int ConditionTest::ConditionChecker::Main() { |
int ConditionTest::ConditionChecker::Main() { |
18 |
condition.WaitAndUnlockIf(!waitFor); |
condition.WaitAndUnlockIf(!waitFor); |
19 |
resource++; |
resource++; |
20 |
|
return 0; |
21 |
} |
} |
22 |
|
|
23 |
|
|
24 |
// ConditionSetter |
// ConditionSetter |
25 |
|
|
26 |
ConditionTest::ConditionSetter::ConditionSetter(Condition* condition, bool toSet) : Thread(false, 0, -4) { |
ConditionTest::ConditionSetter::ConditionSetter(Condition* condition, bool toSet) : Thread(false, false, 0, -4) { |
27 |
resource = 0; |
resource = 0; |
28 |
this->toSet = toSet; |
this->toSet = toSet; |
29 |
this->condition = condition; |
this->condition = condition; |
32 |
int ConditionTest::ConditionSetter::Main() { |
int ConditionTest::ConditionSetter::Main() { |
33 |
condition->Set(toSet); |
condition->Set(toSet); |
34 |
resource++; |
resource++; |
35 |
|
return 0; |
36 |
} |
} |
37 |
|
|
38 |
|
|
47 |
int ConditionTest::ConditionCheckerLocking::Main() { |
int ConditionTest::ConditionCheckerLocking::Main() { |
48 |
staticcondition.WaitIf(!waitFor); |
staticcondition.WaitIf(!waitFor); |
49 |
resource++; |
resource++; |
50 |
while (!doUnlock) usleep(1000); // sleep until ordered to unlock the condition again |
while (!doUnlock) { |
51 |
|
usleep(1000); // sleep until ordered to unlock the condition again |
52 |
|
#if CONFIG_PTHREAD_TESTCANCEL |
53 |
|
TestCancel(); |
54 |
|
#endif |
55 |
|
} |
56 |
staticcondition.Unlock(); |
staticcondition.Unlock(); |
57 |
|
return 0; |
58 |
} |
} |
59 |
|
|
60 |
|
|