Panda3D
pipelineCyclerDummyImpl.h
1 // Filename: pipelineCyclerDummyImpl.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 PIPELINECYCLERDUMMYIMPL_H
16 #define PIPELINECYCLERDUMMYIMPL_H
17 
18 #include "pandabase.h"
19 
20 #if defined(DO_PIPELINING) && !defined(HAVE_THREADS)
21 
22 #include "cycleData.h"
23 #include "pipeline.h"
24 #include "pointerTo.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : PipelineCyclerDummyImpl
28 // Description : This is a simple, single-threaded-only implementation
29 // of PipelineCyclerBase. It is only compiled when
30 // DO_PIPELINING is defined, but threading is not
31 // available, which is usually the case only in
32 // development mode.
33 //
34 // This implmentation is similar in principle to
35 // PipelineCyclerTrivialImpl, except it does basic
36 // sanity checking to ensure that you use the interface
37 // in a reasonable way consistent with its design (e.g.,
38 // read() is balanced with release_read(), etc.).
39 //
40 // This is defined as a struct instead of a class,
41 // mainly to be consistent with
42 // PipelineCyclerTrivialImpl.
43 ////////////////////////////////////////////////////////////////////
44 struct EXPCL_PANDA_PIPELINE PipelineCyclerDummyImpl {
45 public:
46  INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = NULL);
47  INLINE PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl &copy);
48  INLINE void operator = (const PipelineCyclerDummyImpl &copy);
49  INLINE ~PipelineCyclerDummyImpl();
50 
51  INLINE void acquire(Thread *current_thread = NULL);
52  INLINE void release();
53 
54  INLINE const CycleData *read_unlocked(Thread *current_thread) const;
55  INLINE const CycleData *read(Thread *current_thread) const;
56  INLINE void increment_read(const CycleData *pointer) const;
57  INLINE void release_read(const CycleData *pointer) const;
58 
59  INLINE CycleData *write(Thread *current_thread);
60  INLINE CycleData *write_upstream(bool force_to_0, Thread *current_thread);
61  INLINE CycleData *elevate_read(const CycleData *pointer, Thread *current_thread);
62  INLINE CycleData *elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread);
63  INLINE void increment_write(CycleData *pointer) const;
64  INLINE void release_write(CycleData *pointer);
65 
66  INLINE int get_num_stages();
67  INLINE const CycleData *read_stage_unlocked(int pipeline_stage) const;
68  INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const;
69  INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const;
70  INLINE CycleData *write_stage(int pipeline_stage, Thread *current_thread);
71  INLINE CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread);
72  INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread);
73  INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer,
74  bool force_to_0, Thread *current_thread);
75  INLINE void release_write_stage(int pipeline_stage, CycleData *pointer);
76 
77  INLINE TypeHandle get_parent_type() const;
78 
79  INLINE CycleData *cheat() const;
80  INLINE int get_read_count() const;
81  INLINE int get_write_count() const;
82 
83 private:
84  PT(CycleData) _data;
85  Pipeline *_pipeline;
86  short _read_count, _write_count;
87  short _locked;
88 };
89 
90 #include "pipelineCyclerDummyImpl.I"
91 
92 #endif // DO_PIPELINING && !HAVE_THREADS
93 
94 #endif
95 
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:50
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