00001 #ifndef CONDITION_H 00002 #define CONDITION_H 00003 00004 #include <pthread.h> 00005 00006 class Condition 00007 { 00008 public: 00009 Condition(int init_value = 0, char *title = 0); 00010 ~Condition(); 00011 00012 // Reset to init_value whether locked or not. 00013 void reset(); 00014 // Block if value <= 0, then decrease value 00015 void lock(char *location = 0); 00016 // Increase value 00017 void unlock(); 00018 // Block for requested duration if value <= 0. 00019 // value is decreased whether or not the condition is unlocked in time 00020 int timed_lock(int microseconds, char *location = 0); 00021 int get_value(); 00022 00023 pthread_cond_t cond; 00024 pthread_mutex_t mutex; 00025 int value; 00026 int init_value; 00027 char *title; 00028 }; 00029 00030 00031 #endif
1.4.4