Panda3D
pipelineCyclerDummyImpl.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file pipelineCyclerDummyImpl.h
10  * @author drose
11  * @date 2006-01-31
12  */
13 
14 #ifndef PIPELINECYCLERDUMMYIMPL_H
15 #define PIPELINECYCLERDUMMYIMPL_H
16 
17 #include "pandabase.h"
18 
19 #if defined(DO_PIPELINING) && !defined(HAVE_THREADS)
20 
21 #include "cycleData.h"
22 #include "pipeline.h"
23 #include "pointerTo.h"
24 
25 /**
26  * This is a simple, single-threaded-only implementation of
27  * PipelineCyclerBase. It is only compiled when DO_PIPELINING is defined, but
28  * threading is not available, which is usually the case only in development
29  * mode.
30  *
31  * This implmentation is similar in principle to PipelineCyclerTrivialImpl,
32  * except it does basic sanity checking to ensure that you use the interface
33  * in a reasonable way consistent with its design (e.g., read() is balanced
34  * with release_read(), etc.).
35  *
36  * This is defined as a struct instead of a class, mainly to be consistent
37  * with PipelineCyclerTrivialImpl.
38  */
39 struct EXPCL_PANDA_PIPELINE PipelineCyclerDummyImpl {
40 public:
41  INLINE PipelineCyclerDummyImpl(CycleData *initial_data, Pipeline *pipeline = nullptr);
42  INLINE PipelineCyclerDummyImpl(const PipelineCyclerDummyImpl &copy);
43  INLINE void operator = (const PipelineCyclerDummyImpl &copy);
44  INLINE ~PipelineCyclerDummyImpl();
45 
46  INLINE void acquire(Thread *current_thread = nullptr);
47  INLINE void release();
48 
49  INLINE const CycleData *read_unlocked(Thread *current_thread) const;
50  INLINE const CycleData *read(Thread *current_thread) const;
51  INLINE void increment_read(const CycleData *pointer) const;
52  INLINE void release_read(const CycleData *pointer) const;
53 
54  INLINE CycleData *write(Thread *current_thread);
55  INLINE CycleData *write_upstream(bool force_to_0, Thread *current_thread);
56  INLINE CycleData *elevate_read(const CycleData *pointer, Thread *current_thread);
57  INLINE CycleData *elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread);
58  INLINE void increment_write(CycleData *pointer) const;
59  INLINE void release_write(CycleData *pointer);
60 
61  INLINE int get_num_stages();
62  INLINE const CycleData *read_stage_unlocked(int pipeline_stage) const;
63  INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const;
64  INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const;
65  INLINE CycleData *write_stage(int pipeline_stage, Thread *current_thread);
66  INLINE CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread);
67  INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread);
68  INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer,
69  bool force_to_0, Thread *current_thread);
70  INLINE void release_write_stage(int pipeline_stage, CycleData *pointer);
71 
72  INLINE TypeHandle get_parent_type() const;
73 
74  INLINE CycleData *cheat() const;
75  INLINE int get_read_count() const;
76  INLINE int get_write_count() const;
77 
78 private:
79  PT(CycleData) _data;
80  Pipeline *_pipeline;
81  short _read_count, _write_count;
82  short _locked;
83 };
84 
86 
87 #endif // DO_PIPELINING && !HAVE_THREADS
88 
89 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A single page of data maintained by a PipelineCycler.
Definition: cycleData.h:47
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class manages a staged pipeline of data, for instance the render pipeline, so that each stage of...
Definition: pipeline.h:38
A thread; that is, a lightweight process.
Definition: thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81