Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

wefts_counter.h

Go to the documentation of this file.
00001 /*
00002    wefts_counter.h
00003    Shared counter.
00004 
00005    $Id: wefts_counter.h,v 1.4 2003/12/14 09:07:55 jonnymind Exp $
00006 ----------------------------------------------
00007    Begin      : 2003-08-02 00:10
00008    Author     : Giancarlo Niccolai
00009 
00010    Last modified because:
00011 
00012 */
00013 
00014 /**************************************************************************
00015 *   This program is free software; you can redistribute it and/or modify  *
00016 *   it under the terms of the GNU Library General Public License as       *
00017 *   published by the Free Software Foundation; either version 2.1 of the  *
00018 *   License, or (at your option) any later version.                       *
00019 ***************************************************************************/
00020 
00021 #ifndef WT_COUNTER_H
00022 #define WT_COUNTER_H
00023 
00024 #include <wefts_fastcond.h>
00025 
00026 namespace Wefts {
00027 
00049 class Counter: public FastCondition
00050 {
00051 private:
00053    volatile int m_count;
00054 
00055 public:
00059    Counter( int count = 0 ) { m_count = count; }
00060 
00065    int count() { return m_count; }
00066 
00071    void set( int value ) { m_count = value; }
00072 
00078    void count( int value ) { lock(); m_count = value; signal(); unlock();}
00079 
00084    void increment( int amount ) { lock(); m_count += amount; signal(); unlock();}
00085 
00089    void increment() { lock(); m_count ++; signal(); unlock(); }
00090 
00094    void decrement() { lock(); m_count --; signal(); unlock();}
00095 
00101    bool until( int level, double time = 0 );
00102    
00103 };
00104 
00105 }
00106 
00107 #endif
00108 /* end of wefts_counter.h */

Generated on Mon Dec 22 04:12:30 2003 for Wefts by doxygen1.2.18