Panda3D
Loading...
Searching...
No Matches
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
24class 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 */
41struct EXPCL_PANDA_PIPELINE PipelineCyclerTrivialImpl {
42public:
43 INLINE PipelineCyclerTrivialImpl(CycleData *initial_data, Pipeline *pipeline = nullptr);
44 PipelineCyclerTrivialImpl(const PipelineCyclerTrivialImpl &copy) = delete;
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.
CycleData * cheat() const
Returns a pointer without counting it.
void release_write_stage(int pipeline_stage, CycleData *pointer)
Releases a pointer previously obtained via a call to write_stage().
CycleData * elevate_read_stage_upstream(int pipeline_stage, const CycleData *pointer, bool force_to_0, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
const CycleData * read_stage_unlocked(int pipeline_stage) const
Returns a const CycleData pointer, filled with the data for the indicated stage of the pipeline.
void release()
Release the overall lock on the cycler that was grabbed via acquire().
CycleData * elevate_read_upstream(const CycleData *pointer, bool force_to_0, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer, like elevate_read(), but also propagates...
CycleData * elevate_read_stage(int pipeline_stage, const CycleData *pointer, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
CycleData * write(Thread *current_thread)
Returns a non-const CycleData pointer, filled with a unique copy of the data for the current stage of...
void release_write(CycleData *pointer)
Releases a pointer previously obtained via a call to write().
const CycleData * read_unlocked(Thread *current_thread) const
Returns a const CycleData pointer, filled with the data for the current stage of the pipeline as seen...
int get_num_stages()
Returns the number of stages in the pipeline.
CycleData * write_upstream(bool force_to_0, Thread *current_thread)
This special variant on write() will automatically propagate changes back to upstream pipeline stages...
void release_read_stage(int pipeline_stage, const CycleData *pointer) const
Releases a pointer previously obtained via a call to read_stage().
void increment_write(CycleData *pointer) const
Increments the count on a pointer previously retrieved by write(); now the pointer will need to be re...
void increment_read(const CycleData *pointer) const
Increments the count on a pointer previously retrieved by read(); now the pointer will need to be rel...
int get_write_count() const
Returns the number of handles currently outstanding to read the current stage of the data.
CycleData * write_stage_upstream(int pipeline_stage, bool force_to_0, Thread *current_thread)
Returns a pointer suitable for writing to the nth stage of the pipeline.
void acquire(Thread *current_thread=nullptr)
Grabs an overall lock on the cycler.
int get_read_count() const
Returns the number of handles currently outstanding to read the current stage of the data.
const CycleData * read(Thread *current_thread) const
Returns a const CycleData pointer, filled with the data for the current stage of the pipeline as seen...
const CycleData * read_stage(int pipeline_stage, Thread *current_thread) const
Returns a const CycleData pointer, filled with the data for the indicated pipeline stage.
TypeHandle get_parent_type() const
Returns the type of object that owns this cycler, as reported by CycleData::get_parent_type().
CycleData * elevate_read(const CycleData *pointer, Thread *current_thread)
Elevates a currently-held read pointer into a write pointer.
void release_read(const CycleData *pointer) const
Releases a pointer previously obtained via a call to read().
CycleData * write_stage(int pipeline_stage, Thread *current_thread)
Returns a pointer suitable for writing to the nth stage of the pipeline.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.