Collage  0.6.1
barrier.h
00001 
00002 /* Copyright (c) 2006-2012, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *                    2011, Cedric Stalder <cedric.stalder@gmail.com> 
00004  *
00005  * This library is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Lesser General Public License version 2.1 as published
00007  * by the Free Software Foundation.
00008  *  
00009  * This library is distributed in the hope that it will be useful, but WITHOUT
00010  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00011  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00012  * details.
00013  * 
00014  * You should have received a copy of the GNU Lesser General Public License
00015  * along with this library; if not, write to the Free Software Foundation, Inc.,
00016  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00017  */
00018 
00019 #ifndef CO_BARRIER_H
00020 #define CO_BARRIER_H
00021 
00022 #include <co/object.h>   // base class
00023 #include <co/types.h>
00024 
00025 namespace co
00026 {
00027 namespace detail { class Barrier; }
00028 
00030     class Barrier : public Object
00031     {
00032     public:
00044         CO_API Barrier( NodePtr master, const uint32_t height = 0 );
00045 
00047         CO_API Barrier();
00048 
00050         CO_API virtual ~Barrier();
00051 
00060         CO_API void setHeight( const uint32_t height );
00061 
00063         CO_API void increase();
00064 
00066         CO_API uint32_t getHeight() const;
00068 
00078         CO_API void enter( const uint32_t timeout = LB_TIMEOUT_INDEFINITE );
00080 
00081     protected:
00082         virtual void attach( const UUID& id, 
00083                              const uint32_t instanceID );
00084 
00085         virtual ChangeType getChangeType() const { return DELTA; }
00086 
00087         virtual void getInstanceData( DataOStream& os );
00088         virtual void applyInstanceData( DataIStream& is );
00089         virtual void pack( DataOStream& os );
00090         virtual void unpack( DataIStream& is );
00091 
00092     private:
00093         detail::Barrier* const _impl;
00094 
00095         void _cleanup( const uint64_t time );
00096         void _sendNotify( const uint128_t& version, NodePtr node );
00097 
00098         /* The command handlers. */
00099         bool _cmdEnter( Command& command );
00100         bool _cmdEnterReply( Command& command );
00101 
00102         LB_TS_VAR( _thread );
00103     };
00104 }
00105 
00106 #endif // CO_BARRIER_H
00107 
Generated on Mon Nov 26 2012 14:41:44 for Collage 0.6.1 by  doxygen 1.7.6.1