00001 #include "bccounter.h" 00002 #include "mutex.h" 00003 00004 BCCounter::BCCounter() 00005 { 00006 value = 0; 00007 mutex = new Mutex; 00008 } 00009 00010 BCCounter::~BCCounter() 00011 { 00012 delete mutex; 00013 } 00014 00015 void BCCounter::up() 00016 { 00017 mutex->lock("BCCounter::up"); 00018 value++; 00019 printf("BCCounter::up %p %d\n", this, value); 00020 mutex->unlock(); 00021 } 00022 00023 void BCCounter::down() 00024 { 00025 mutex->lock("BCCounter::down"); 00026 value--; 00027 printf("BCCounter::down %p %d\n", this, value); 00028 mutex->unlock(); 00029 }
1.4.4