Panda3D
pipelineCyclerTrivialImpl.h
1 // Filename: pipelineCyclerTrivialImpl.h
2 // Created by: drose (31Jan06)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PIPELINECYCLERTRIVIALIMPL_H
16 #define PIPELINECYCLERTRIVIALIMPL_H
17 
18 #include "pandabase.h"
19 
20 #ifndef DO_PIPELINING
21 
22 #include "thread.h"
23 #include "cycleData.h"
24 
25 class Pipeline;
26 
27 ////////////////////////////////////////////////////////////////////
28 // Class : PipelineCyclerTrivialImpl
29 // Description : This is the trivial, non-threaded implementation of
30 // PipelineCyclerBase. It is only compiled when
31 // DO_PIPELINING is not defined (which usually implies
32 // that threading is not available).
33 //
34 // This implementation is designed to do as little as
35 // possible, and to compile to nothing, or almost
36 // nothing. It doesn't actually support pipelining in
37 // any way. It doesn't even perform any sanity checks
38 // to speak of. It's designed for a strictly
39 // single-threaded application, and its purpose is to be
40 // as low-overhead as possible.
41 //
42 // We define this as a struct instead of a class to
43 // emphasize the importance of byte placement within the
44 // object, so that the inherited struct's data is likely
45 // to be placed by the compiler at the "this" pointer.
46 ////////////////////////////////////////////////////////////////////
47 struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl {
48 public:
49  INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = NULL);
50 private:
51  INLINE PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl &copy);
52  INLINE void operator = (const PipelineCyclerTrivialImpl &copy);
53 public:
54  INLINE ~PipelineCyclerTrivialImpl();
55 
56  INLINE void acquire(Thread *current_thread = NULL);
57  INLINE void release();
58 
59  INLINE const CycleData *read_unlocked(Thread *current_thread) const;
60  INLINE const CycleData *read(Thread *current_thread) const;
61  INLINE void increment_read(const CycleData *pointer) const;
62  INLINE void release_read(const CycleData *pointer) const;
63 
64  INLINE CycleData *write(Thread *current_thread);
65  INLINE CycleData *write_upstream(bool force_to_0, Thread *current_thread);
66  INLINE CycleData *elevate_read(const CycleData *pointer, Thread *current_thread);
67  INLINE CycleData *elevate_read_upstream(const CycleData *pointer, bool force_to_0,
68  Thread *current_thread);
69  INLINE void increment_write(CycleData *pointer) const;
70  INLINE void release_write(CycleData *pointer);
71 
72  INLINE int get_num_stages();
73  INLINE const CycleData *read_stage_unlocked(int pipeline_stage) const;
74  INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const;
75  INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const;
76  INLINE CycleData *write_stage(int pipeline_stage, Thread *current_thread);
77  INLINE CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0,
78  Thread *current_thread);
79  INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer,
80  Thread *current_thread);
81  INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer,
82  bool force_to_0, Thread *current_thread);
83  INLINE void release_write_stage(int pipeline_stage, CycleData *pointer);
84 
85  INLINE TypeHandle get_parent_type() const;
86 
87  INLINE CycleData *cheat() const;
88  INLINE int get_read_count() const;
89  INLINE int get_write_count() const;
90 
91  // In a trivial implementation, we only need to store the CycleData
92  // pointer. Actually, we don't even need to do that, if we're lucky
93  // and the compiler doesn't do anything funny with the struct
94  // layout.
95  #ifndef SIMPLE_STRUCT_POINTERS
96  CycleData *_data;
97  #endif // SIMPLE_STRUCT_POINTERS
98 };
99 
100 #include "pipelineCyclerTrivialImpl.I"
101 
102 #endif // !DO_PIPELINING
103 
104 #endif
105 
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
This is the trivial, non-threaded implementation of PipelineCyclerBase.
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
Definition: pipeline.h:41
A thread; that is, a lightweight process.
Definition: thread.h:51
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85