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

wefts_barrier.h

Go to the documentation of this file.
00001 /*
00002    wefts_barrier.h
00003    Execution barrier for wefts.
00004 
00005    $Id: wefts_barrier.h,v 1.2 2003/08/05 15:40:20 jonnymind Exp $
00006 ---------------------------------------------
00007    Begin      : 2003-08-03 17:50
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 
00022 #ifndef WT_BARRIER_H
00023 #define WT_BARRIER_H
00024 
00025 #include <wefts_fastcond.h>
00026 
00027 
00028 namespace Wefts {
00029 
00043 class Barrier {
00044 private:
00045    volatile unsigned int m_treshold;
00046    volatile unsigned int m_subscribed;
00047    FastCondition m_cond;   // should be automagically initialized and removed
00048    volatile bool m_release;
00049    volatile bool m_open;
00050 
00051 public:
00060    Barrier( unsigned int treshold=0, bool open = false );
00061 
00065    void wait();
00066 
00068    inline unsigned int waiting() { return m_subscribed; }
00069 
00071    inline unsigned int treshold() { return m_treshold; }
00072 
00075    inline bool blocking() { return !m_open; }
00076 
00081    void treshold( unsigned int th );
00082 
00087    void release();
00088 
00093    void open();
00094 
00097    void close();
00098 
00099 };
00100 
00101 }
00102 
00103 #endif
00104 /* end of wefts_barrier.h */

Generated on Tue Aug 5 18:09:00 2003 for Wefts by doxygen1.2.18