23 INLINE
void PipelineCyclerTrueImpl::
25 TAU_PROFILE(
"void PipelineCyclerTrueImpl::acquire()",
" ", TAU_USER);
36 INLINE
void PipelineCyclerTrueImpl::
37 acquire(
Thread *current_thread) {
38 TAU_PROFILE(
"void PipelineCyclerTrueImpl::acquire(Thread *)",
" ", TAU_USER);
39 _lock.acquire(current_thread);
48 INLINE
void PipelineCyclerTrueImpl::
50 TAU_PROFILE(
"void PipelineCyclerTrueImpl::release()",
" ", TAU_USER);
68 INLINE
const CycleData *PipelineCyclerTrueImpl::
69 read_unlocked(
Thread *current_thread)
const {
70 TAU_PROFILE(
"const CycleData *PipelineCyclerTrueImpl::read_unlocked(Thread *)",
" ", TAU_USER);
73 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
75 return _data[pipeline_stage]._cdata;
89 INLINE
const CycleData *PipelineCyclerTrueImpl::
90 read(
Thread *current_thread)
const {
91 TAU_PROFILE(
"const CycleData *PipelineCyclerTrueImpl::read(Thread *)",
" ", TAU_USER);
94 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
96 _lock.acquire(current_thread);
97 return _data[pipeline_stage]._cdata;
107 INLINE
void PipelineCyclerTrueImpl::
108 increment_read(
const CycleData *pointer)
const {
109 TAU_PROFILE(
"void PipelineCyclerTrueImpl::increment_read(const CycleData *)",
" ", TAU_USER);
112 nassertv(pipeline_stage >= 0 && pipeline_stage < _num_stages);
113 nassertv(_data[pipeline_stage]._cdata == pointer);
115 _lock.elevate_lock();
124 INLINE
void PipelineCyclerTrueImpl::
125 release_read(
const CycleData *pointer)
const {
126 TAU_PROFILE(
"void PipelineCyclerTrueImpl::release_read(const CycleData *)",
" ", TAU_USER);
129 nassertv(pipeline_stage >= 0 && pipeline_stage < _num_stages);
130 nassertv(_data[pipeline_stage]._cdata == pointer);
151 INLINE
CycleData *PipelineCyclerTrueImpl::
152 write(
Thread *current_thread) {
153 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::write(Thread *)",
" ", TAU_USER);
186 INLINE
CycleData *PipelineCyclerTrueImpl::
187 write_upstream(
bool force_to_0,
Thread *current_thread) {
188 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::write_upstream(bool, Thread *)",
" ", TAU_USER);
202 INLINE
CycleData *PipelineCyclerTrueImpl::
204 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::elevate_read(const CycleData *)",
" ", TAU_USER);
207 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
208 nassertr(_data[pipeline_stage]._cdata == pointer, NULL);
210 CycleData *new_pointer = write(current_thread);
223 INLINE
CycleData *PipelineCyclerTrueImpl::
224 elevate_read_upstream(
const CycleData *pointer,
bool force_to_0,
Thread *current_thread) {
225 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::elevate_read_upstream(const CycleData *, bool)",
" ", TAU_USER);
228 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
229 nassertr(_data[pipeline_stage]._cdata == pointer, NULL);
231 CycleData *new_pointer = write_upstream(force_to_0, current_thread);
243 INLINE
void PipelineCyclerTrueImpl::
244 increment_write(
CycleData *pointer)
const {
245 TAU_PROFILE(
"void PipelineCyclerTrueImpl::increment_write(CycleData *)",
" ", TAU_USER);
248 nassertv(pipeline_stage >= 0 && pipeline_stage < _num_stages);
249 nassertv(_data[pipeline_stage]._cdata == pointer);
251 ++(_data[pipeline_stage]._writes_outstanding);
252 _lock.elevate_lock();
261 INLINE
void PipelineCyclerTrueImpl::
263 TAU_PROFILE(
"void PipelineCyclerTrueImpl::release_write(CycleData *)",
" ", TAU_USER);
265 return release_write_stage(pipeline_stage, pointer);
273 INLINE
int PipelineCyclerTrueImpl::
286 INLINE
const CycleData *PipelineCyclerTrueImpl::
287 read_stage_unlocked(
int pipeline_stage)
const {
288 TAU_PROFILE(
"const CycleData *PipelineCyclerTrueImpl::read_stage_unlocked(int)",
" ", TAU_USER);
290 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
292 return _data[pipeline_stage]._cdata;
306 INLINE
const CycleData *PipelineCyclerTrueImpl::
307 read_stage(
int pipeline_stage,
Thread *current_thread)
const {
308 TAU_PROFILE(
"const CycleData *PipelineCyclerTrueImpl::read_stage(int, Thread *)",
" ", TAU_USER);
310 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
312 _lock.acquire(current_thread);
313 return _data[pipeline_stage]._cdata;
322 INLINE
void PipelineCyclerTrueImpl::
323 release_read_stage(
int pipeline_stage,
const CycleData *pointer)
const {
324 TAU_PROFILE(
"void PipelineCyclerTrueImpl::release_read_stage(int, const CycleData *)",
" ", TAU_USER);
326 nassertv(pipeline_stage >= 0 && pipeline_stage < _num_stages);
327 nassertv(_data[pipeline_stage]._cdata == pointer);
341 INLINE
CycleData *PipelineCyclerTrueImpl::
342 elevate_read_stage(
int pipeline_stage,
const CycleData *pointer,
344 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)",
" ", TAU_USER);
346 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
347 nassertr(_data[pipeline_stage]._cdata == pointer, NULL);
349 CycleData *new_pointer = write_stage(pipeline_stage, current_thread);
363 INLINE
CycleData *PipelineCyclerTrueImpl::
364 elevate_read_stage_upstream(
int pipeline_stage,
const CycleData *pointer,
365 bool force_to_0,
Thread *current_thread) {
366 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::elevate_read_stage(int, const CycleData *)",
" ", TAU_USER);
368 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
369 nassertr(_data[pipeline_stage]._cdata == pointer, NULL);
372 write_stage_upstream(pipeline_stage, force_to_0, current_thread);
383 INLINE
void PipelineCyclerTrueImpl::
384 release_write_stage(
int pipeline_stage,
CycleData *pointer) {
385 TAU_PROFILE(
"void PipelineCyclerTrueImpl::release_write_stage(int, const CycleData *)",
" ", TAU_USER);
387 nassertv(pipeline_stage >= 0 && pipeline_stage < _num_stages);
388 nassertv(_data[pipeline_stage]._cdata == pointer);
389 nassertv(_data[pipeline_stage]._writes_outstanding > 0);
391 --(_data[pipeline_stage]._writes_outstanding);
402 get_parent_type()
const {
403 return _data[0]._cdata->get_parent_type();
416 INLINE
CycleData *PipelineCyclerTrueImpl::
418 TAU_PROFILE(
"CycleData *PipelineCyclerTrueImpl::cheat()",
" ", TAU_USER);
420 nassertr(pipeline_stage >= 0 && pipeline_stage < _num_stages, NULL);
421 return _data[pipeline_stage]._cdata;
431 INLINE
int PipelineCyclerTrueImpl::
432 get_read_count()
const {
444 INLINE
int PipelineCyclerTrueImpl::
445 get_write_count()
const {
457 INLINE PT(
CycleData) PipelineCyclerTrueImpl::
459 TAU_PROFILE(
"PT(CycleData) PipelineCyclerTrueImpl::cycle_2()",
" ", TAU_USER);
460 PT(
CycleData) last_val = _data[1]._cdata.p();
461 nassertr(_lock.debug_is_locked(), last_val);
462 nassertr(_dirty, last_val);
463 nassertr(_num_stages == 2, last_val);
465 nassertr(_data[1]._writes_outstanding == 0, last_val);
466 _data[1]._cdata = _data[0]._cdata;
482 INLINE PT(
CycleData) PipelineCyclerTrueImpl::
484 TAU_PROFILE(
"PT(CycleData) PipelineCyclerTrueImpl::cycle_3()",
" ", TAU_USER);
485 PT(
CycleData) last_val = _data[2]._cdata.p();
486 nassertr(_lock.debug_is_locked(), last_val);
487 nassertr(_dirty, last_val);
488 nassertr(_num_stages == 3, last_val);
490 nassertr(_data[2]._writes_outstanding == 0, last_val);
491 nassertr(_data[1]._writes_outstanding == 0, last_val);
492 _data[2]._cdata = _data[1]._cdata;
493 _data[1]._cdata = _data[0]._cdata;
495 if (_data[2]._cdata == _data[1]._cdata) {
508 INLINE PipelineCyclerTrueImpl::CyclerMutex::
509 CyclerMutex(PipelineCyclerTrueImpl *cycler) {
520 INLINE PipelineCyclerTrueImpl::CycleDataNode::
522 _writes_outstanding(0)
531 INLINE PipelineCyclerTrueImpl::CycleDataNode::
532 CycleDataNode(
const PipelineCyclerTrueImpl::CycleDataNode ©) :
534 _writes_outstanding(0)
543 INLINE PipelineCyclerTrueImpl::CycleDataNode::
545 nassertv(_writes_outstanding == 0);
553 INLINE
void PipelineCyclerTrueImpl::CycleDataNode::
554 operator = (
const PipelineCyclerTrueImpl::CycleDataNode ©) {
555 _cdata = copy._cdata;
A single page of data maintained by a PipelineCycler.
A thread; that is, a lightweight process.
TypeHandle is the identifier used to differentiate C++ class types.
static int get_current_pipeline_stage()
Returns the integer pipeline stage associated with the current thread.
int get_pipeline_stage() const
Returns the Pipeline stage number associated with this thread.