Panda3D
|
00001 // Filename: pipelineCyclerTrivialImpl.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 PIPELINECYCLERTRIVIALIMPL_H 00016 #define PIPELINECYCLERTRIVIALIMPL_H 00017 00018 #include "pandabase.h" 00019 00020 #ifndef DO_PIPELINING 00021 00022 #include "thread.h" 00023 #include "cycleData.h" 00024 00025 class Pipeline; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Class : PipelineCyclerTrivialImpl 00029 // Description : This is the trivial, non-threaded implementation of 00030 // PipelineCyclerBase. It is only compiled when 00031 // DO_PIPELINING is not defined (which usually implies 00032 // that threading is not available). 00033 // 00034 // This implementation is designed to do as little as 00035 // possible, and to compile to nothing, or almost 00036 // nothing. It doesn't actually support pipelining in 00037 // any way. It doesn't even perform any sanity checks 00038 // to speak of. It's designed for a strictly 00039 // single-threaded application, and its purpose is to be 00040 // as low-overhead as possible. 00041 // 00042 // We define this as a struct instead of a class to 00043 // emphasize the importance of byte placement within the 00044 // object, so that the inherited struct's data is likely 00045 // to be placed by the compiler at the "this" pointer. 00046 //////////////////////////////////////////////////////////////////// 00047 struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl { 00048 public: 00049 INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL); 00050 private: 00051 INLINE PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl ©); 00052 INLINE void operator = (const PipelineCyclerTrivialImpl ©); 00053 public: 00054 INLINE ~PipelineCyclerTrivialImpl(); 00055 00056 INLINE void acquire(Thread *current_thread = NULL); 00057 INLINE void release(); 00058 00059 INLINE const CycleData *read_unlocked(Thread *current_thread) const; 00060 INLINE const CycleData *read(Thread *current_thread) const; 00061 INLINE void increment_read(const CycleData *pointer) const; 00062 INLINE void release_read(const CycleData *pointer) const; 00063 00064 INLINE CycleData *write(Thread *current_thread); 00065 INLINE CycleData *write_upstream(bool force_to_0, Thread *current_thread); 00066 INLINE CycleData *elevate_read(const CycleData *pointer, Thread *current_thread); 00067 INLINE CycleData *elevate_read_upstream(const CycleData *pointer, bool force_to_0, 00068 Thread *current_thread); 00069 INLINE void increment_write(CycleData *pointer) const; 00070 INLINE void release_write(CycleData *pointer); 00071 00072 INLINE int get_num_stages(); 00073 INLINE const CycleData *read_stage_unlocked(int pipeline_stage) const; 00074 INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const; 00075 INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const; 00076 INLINE CycleData *write_stage(int pipeline_stage, Thread *current_thread); 00077 INLINE CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0, 00078 Thread *current_thread); 00079 INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer, 00080 Thread *current_thread); 00081 INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, 00082 bool force_to_0, Thread *current_thread); 00083 INLINE void release_write_stage(int pipeline_stage, CycleData *pointer); 00084 00085 INLINE TypeHandle get_parent_type() const; 00086 00087 INLINE CycleData *cheat() const; 00088 INLINE int get_read_count() const; 00089 INLINE int get_write_count() const; 00090 00091 // In a trivial implementation, we only need to store the CycleData 00092 // pointer. Actually, we don't even need to do that, if we're lucky 00093 // and the compiler doesn't do anything funny with the struct 00094 // layout. 00095 #ifndef SIMPLE_STRUCT_POINTERS 00096 CycleData *_data; 00097 #endif // SIMPLE_STRUCT_POINTERS 00098 }; 00099 00100 #include "pipelineCyclerTrivialImpl.I" 00101 00102 #endif // !DO_PIPELINING 00103 00104 #endif 00105