Qore Programming Language  0.8.3
include/qore/QoreCounter.h (4311)
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */
00002 /*
00003   QoreCounter.h
00004 
00005   Qore Programming Language
00006 
00007   Copyright (C) David Nichols 2005 - 2011
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 */
00023 
00024 #ifndef _QORE_QORECOUNTER_H
00025 
00026 #define _QORE_QORECOUNTER_H
00027 
00028 #include <qore/Qore.h>
00029 #include <qore/QoreCondition.h>
00030 
00032 class QoreCounter
00033 {
00034    private:
00036       struct qore_counter_private *priv;
00037 
00039       DLLLOCAL QoreCounter(const QoreCounter&);
00040 
00042       DLLLOCAL QoreCounter& operator=(const QoreCounter&);
00043 
00044    public:
00046       DLLEXPORT QoreCounter(int nc = 0);
00047 
00049       DLLEXPORT ~QoreCounter();
00050 
00052       DLLEXPORT void destructor(class ExceptionSink *xsink);
00053 
00055       DLLEXPORT void inc();
00056 
00058 
00062       DLLEXPORT void dec(class ExceptionSink *xsink);
00063 
00065 
00071       DLLEXPORT int waitForZero(class ExceptionSink *xsink, int timeout_ms = 0);
00072 
00074       DLLEXPORT int getCount() const;
00075 
00077       DLLEXPORT int getWaiting() const;
00078 
00079       // internal use only - for internal counters
00080       DLLLOCAL void waitForZero();
00081       DLLLOCAL void dec();
00082 };
00083 
00084 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines