Panda3D
pipelineCyclerTrivialImpl.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 pipelineCyclerTrivialImpl.h
10  * @author drose
11  * @date 2006-01-31
12  */
13 
14 #ifndef PIPELINECYCLERTRIVIALIMPL_H
15 #define PIPELINECYCLERTRIVIALIMPL_H
16 
17 #include "pandabase.h"
18 
19 #ifndef DO_PIPELINING
20 
21 #include "thread.h"
22 #include "cycleData.h"
23 
24 class Pipeline;
25 
26 /**
27  * This is the trivial, non-threaded implementation of PipelineCyclerBase. It
28  * is only compiled when DO_PIPELINING is not defined (which usually implies
29  * that threading is not available).
30  *
31  * This implementation is designed to do as little as possible, and to compile
32  * to nothing, or almost nothing. It doesn't actually support pipelining in
33  * any way. It doesn't even perform any sanity checks to speak of. It's
34  * designed for a strictly single-threaded application, and its purpose is to
35  * be as low-overhead as possible.
36  *
37  * We define this as a struct instead of a class to emphasize the importance
38  * of byte placement within the object, so that the inherited struct's data is
39  * likely to be placed by the compiler at the "this" pointer.
40  */
41 struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl {
42 public:
43  INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = nullptr);
45  ~PipelineCyclerTrivialImpl() = default;
46 
47  PipelineCyclerTrivialImpl &operator = (const PipelineCyclerTrivialImpl &copy) = delete;
48 
49  INLINE void acquire(Thread *current_thread = nullptr);
50  INLINE void release();
51 
52  INLINE const CycleData *read_unlocked(Thread *current_thread) const;
53  INLINE const CycleData *read(Thread *current_thread) const;
54  INLINE void increment_read(const CycleData *pointer) const;
55  INLINE void release_read(const CycleData *pointer) const;
56 
57  INLINE CycleData *write(Thread *current_thread);
58  INLINE CycleData *write_upstream(bool force_to_0, Thread *current_thread);
59  INLINE CycleData *elevate_read(const CycleData *pointer, Thread *current_thread);
60  INLINE CycleData *elevate_read_upstream(const CycleData *pointer, bool force_to_0,
61  Thread *current_thread);
62  INLINE void increment_write(CycleData *pointer) const;
63  INLINE void release_write(CycleData *pointer);
64 
65  INLINE int get_num_stages();
66  INLINE const CycleData *read_stage_unlocked(int pipeline_stage) const;
67  INLINE const CycleData *read_stage(int pipeline_stage, Thread *current_thread) const;
68  INLINE void release_read_stage(int pipeline_stage, const CycleData *pointer) const;
69  INLINE CycleData *write_stage(int pipeline_stage, Thread *current_thread);
70  INLINE CycleData *write_stage_upstream(int pipeline_stage, bool force_to_0,
71  Thread *current_thread);
72  INLINE CycleData *elevate_read_stage(int pipeline_stage, const CycleData *pointer,
73  Thread *current_thread);
74  INLINE CycleData *elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer,
75  bool force_to_0, Thread *current_thread);
76  INLINE void release_write_stage(int pipeline_stage, CycleData *pointer);
77 
78  INLINE TypeHandle get_parent_type() const;
79 
80  INLINE CycleData *cheat() const;
81  INLINE int get_read_count() const;
82  INLINE int get_write_count() const;
83 
84  // In a trivial implementation, we only need to store the CycleData pointer.
85  // Actually, we don't even need to do that, if we're lucky and the compiler
86  // doesn't do anything funny with the struct layout.
87  #ifndef SIMPLE_STRUCT_POINTERS
88  CycleData *_data;
89  #endif // SIMPLE_STRUCT_POINTERS
90 };
91 
93 
94 #endif // !DO_PIPELINING
95 
96 #endif
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: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
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 is the trivial, non-threaded implementation of PipelineCyclerBase.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.