diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2004-04-23 03:06:19 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2004-04-23 03:06:19 +0000 |
commit | 8a30729dc5a0364cbfb2750c94e13015ada77784 (patch) | |
tree | 517d13a21fce9eefd531d325e4edb5ba94f70e58 /docs | |
parent | 6cc42ca0d9f466c92dd2d6d977f4bbfac9de7012 (diff) | |
download | ATCD-8a30729dc5a0364cbfb2750c94e13015ada77784.tar.gz |
ChangeLogTag:Thu Apr 22 20:01:12 2004 Ossama Othman <ossama@dre.vanderbilt.edu>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/tutorials/016/Condition_i.cpp | 20 | ||||
-rw-r--r-- | docs/tutorials/016/Condition_i.h | 14 | ||||
-rw-r--r-- | docs/tutorials/016/condition.cpp | 9 |
3 files changed, 24 insertions, 19 deletions
diff --git a/docs/tutorials/016/Condition_i.cpp b/docs/tutorials/016/Condition_i.cpp index 20377f3c935..eebd12a0b12 100644 --- a/docs/tutorials/016/Condition_i.cpp +++ b/docs/tutorials/016/Condition_i.cpp @@ -146,56 +146,56 @@ Condition & Condition::operator= ( value_t _value ) wants to check for a desired condition. When the function object returns non-zero, the condition is met and we leave. */ -int Condition::operator== ( Condition::Compare & _compare ) +bool Condition::operator== ( Condition::Compare & _compare ) { guard_t guard(mutex_); while( ! _compare(this->value()) ) condition().wait(); - return 0; + return false; } // As long as the variable equals _value, we wait... -int Condition::operator== ( value_t _value ) +bool Condition::operator== ( value_t _value ) { guard_t guard(mutex_); while( value() == _value ) condition().wait(); - return 0; + return false; } // As long as the variable is not equal to _value, we wait... -int Condition::operator!= ( value_t _value ) +bool Condition::operator!= ( value_t _value ) { guard_t guard(mutex_); while( value() != _value ) condition().wait(); - return 0; + return false; } // As long as the variable is less than or equal to _value, we wait... -int Condition::operator<= ( value_t _value ) +bool Condition::operator<= ( value_t _value ) { guard_t guard(mutex_); while( value() <= _value ) condition().wait(); - return 0; + return false; } // As long as the variable is greater than or equal to _value, we wait... -int Condition::operator>= ( value_t _value ) +bool Condition::operator>= ( value_t _value ) { guard_t guard(mutex_); while( value() >= _value ) condition().wait(); - return 0; + return false; } diff --git a/docs/tutorials/016/Condition_i.h b/docs/tutorials/016/Condition_i.h index a265d9ac670..c126ca76639 100644 --- a/docs/tutorials/016/Condition_i.h +++ b/docs/tutorials/016/Condition_i.h @@ -1,3 +1,5 @@ +// -*- C++ -*- +// // $Id$ #ifndef CONDITION_H @@ -53,7 +55,7 @@ public: /* These four operators perform the actual waiting. For instance: - operator!=(int _value) + bool operator!=(int _value) is implemented as: @@ -74,19 +76,19 @@ public: ... */ // As long as the condition variable is NOT EQUAL TO <value>, we wait - int operator!= (value_t value); + bool operator!= (value_t value); // As long as the condition variable is EXACTLY EQUAL TO <value>, we // wait - int operator== (value_t value); + bool operator== (value_t value); // As long as the condition variable is LESS THAN OR EQUAL TO // <value>, we wait - int operator<= (value_t value); + bool operator<= (value_t value); // As long as the condition variable is GREATER THAN OR EQUAL TO // <value>, we wait - int operator>= (value_t value); + bool operator>= (value_t value); // Return the value of the condition variable operator value_t (void); @@ -107,7 +109,7 @@ public: This is a little odd since we're not really testing equality. Just be sure that _compare(value_) will return non-zero when you consider the condition to be met. */ - int operator== (Compare & compare); + bool operator== (Compare & compare); private: // Prevent copy construction and assignment. diff --git a/docs/tutorials/016/condition.cpp b/docs/tutorials/016/condition.cpp index 7af7326f5bf..44089f09ad5 100644 --- a/docs/tutorials/016/condition.cpp +++ b/docs/tutorials/016/condition.cpp @@ -93,7 +93,7 @@ int Test::svc(void) return(0); } -/* Test Condition::operator!=() +/* Test bool Condition::operator!=() The task's svc() method will increment the condition variable and then wait until the variable's value reaches max_threads_. */ @@ -120,7 +120,7 @@ public: } }; -/* Test Condition::operator>=() +/* Test bool Condition::operator>=() Each svc() method will decrement the condition variable and wait until it is less than max_threads_. To do this correctly, we have to be careful where we start the condition variable. @@ -150,7 +150,10 @@ public: } }; -/* Test Condition::operator<=() +/* Test + + bool Condition::operator<=() + This time we will increment the condition until it is greater than max_threads_. Again, we have to be careful where we start the value and how we increment. |