Panda3D

pipelineCyclerDummyImpl.h

00001 // Filename: pipelineCyclerDummyImpl.h
00002 // Created by:  drose (31Jan06)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PIPELINECYCLERDUMMYIMPL_H
00016 #define PIPELINECYCLERDUMMYIMPL_H
00017 
00018 #include "pandabase.h"
00019 
00020 #if defined(DO_PIPELINING) && !defined(HAVE_THREADS)
00021 
00022 #include "cycleData.h"
00023 #include "pipeline.h"
00024 #include "pointerTo.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : PipelineCyclerDummyImpl
00028 // Description : This is a simple, single-threaded-only implementation
00029 //               of PipelineCyclerBase.  It is only compiled when
00030 //               DO_PIPELINING is defined, but threading is not
00031 //               available, which is usually the case only in
00032 //               development mode.
00033 //
00034 //               This implmentation is similar in principle to
00035 //               PipelineCyclerTrivialImpl, except it does basic
00036 //               sanity checking to ensure that you use the interface
00037 //               in a reasonable way consistent with its design (e.g.,
00038 //               read() is balanced with release_read(), etc.).
00039 //
00040 //               This is defined as a struct instead of a class,
00041 //               mainly to be consistent with
00042 //               PipelineCyclerTrivialImpl.
00043 ////////////////////////////////////////////////////////////////////
00044 struct EXPCL_PANDA_PIPELINE PipelineCyclerDummyImpl {
00045 public:
00046   INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = NULL);
00047   INLINE PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl &copy);
00048   INLINE void operator = (const PipelineCyclerDummyImpl &copy);
00049   INLINE ~PipelineCyclerDummyImpl();
00050 
00051   INLINE void acquire(Thread *current_thread = NULL);
00052   INLINE void release();
00053 
00054   INLINE const CycleData *read_unlocked(Thread *current_thread) const;
00055   INLINE const CycleData *read(Thread *current_thread) const;
00056   INLINE void increment_read(const CycleData *pointer) const;
00057   INLINE void release_read(const CycleData *pointer) const;
00058 
00059   INLINE CycleData *write(Thread *current_thread);
00060   INLINE CycleData *write_upstream(bool force_to_0, Thread *current_thread);
00061   INLINE CycleData *elevate_read(const CycleData *pointer, Thread *current_thread);
00062   INLINE CycleData *elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread);
00063   INLINE void increment_write(CycleData *pointer) const;
00064   INLINE void release_write(CycleData *pointer);
00065 
00066   INLINE int get_num_stages();
00067   INLINE const CycleData *read_stage_unlocked(int pipeline_stage) const;
00068   INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const;
00069   INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const;
00070   INLINE CycleData *write_stage(int pipeline_stage, Thread *current_thread);
00071   INLINE CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread);
00072   INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread);
00073   INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer,
00074                                                 bool force_to_0, Thread *current_thread);
00075   INLINE void release_write_stage(int pipeline_stage, CycleData *pointer);
00076 
00077   INLINE TypeHandle get_parent_type() const;
00078 
00079   INLINE CycleData *cheat() const;
00080   INLINE int get_read_count() const;
00081   INLINE int get_write_count() const;
00082 
00083 private:
00084   PT(CycleData) _data;
00085   Pipeline *_pipeline;
00086   short _read_count, _write_count;
00087   short _locked;
00088 };
00089 
00090 #include "pipelineCyclerDummyImpl.I"
00091 
00092 #endif  // DO_PIPELINING && !HAVE_THREADS
00093 
00094 #endif
00095 
 All Classes Functions Variables Enumerations