Panda3D
Loading...
Searching...
No Matches
pipelineCyclerLinks.I
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 pipelineCyclerLinks.I
10 * @author drose
11 * @date 2006-02-16
12 */
13
14#ifdef THREADED_PIPELINE
15/**
16 *
17 */
18INLINE PipelineCyclerLinks::
19PipelineCyclerLinks() {
20#ifndef NDEBUG
21 _next = nullptr;
22 _prev = nullptr;
23#endif
24}
25#endif // THREADED_PIPELINE
26
27#ifdef THREADED_PIPELINE
28/**
29 *
30 */
31INLINE PipelineCyclerLinks::
32~PipelineCyclerLinks() {
33 nassertv(_next == nullptr && _prev == nullptr);
34}
35#endif // THREADED_PIPELINE
36
37#ifdef THREADED_PIPELINE
38/**
39 * When called on an empty object, sets it up to be the head of a linked list.
40 */
41INLINE void PipelineCyclerLinks::
42make_head() {
43 nassertv(_next == nullptr && _prev == nullptr);
44 _next = this;
45 _prev = this;
46}
47#endif // THREADED_PIPELINE
48
49#ifdef THREADED_PIPELINE
50/**
51 * When called on the head of an empty linked list, resets it to an empty
52 * object, for safe destruction.
53 */
54INLINE void PipelineCyclerLinks::
55clear_head() {
56 nassertv(_next == this && _prev == this);
57#ifndef NDEBUG
58 _next = nullptr;
59 _prev = nullptr;
60#endif
61}
62#endif // THREADED_PIPELINE
63
64#ifdef THREADED_PIPELINE
65/**
66 * Removes a PipelineCyclerLinks record from the doubly-linked list.
67 */
68INLINE void PipelineCyclerLinks::
69remove_from_list() {
70 nassertv(_prev->_next == this && _next->_prev == this);
71 _prev->_next = _next;
72 _next->_prev = _prev;
73#ifndef NDEBUG
74 _next = nullptr;
75 _prev = nullptr;
76#endif
77}
78#endif // THREADED_PIPELINE
79
80#ifdef THREADED_PIPELINE
81/**
82 * Adds a PipelineCyclerLinks record before the indicated node in the doubly-
83 * linked list.
84 */
85INLINE void PipelineCyclerLinks::
86insert_before(PipelineCyclerLinks *node) {
87 nassertv(node->_prev->_next == node && node->_next->_prev == node);
88 nassertv(_prev == nullptr &&
89 _next == nullptr);
90 _prev = node->_prev;
91 _next = node;
92 _prev->_next = this;
93 node->_prev = this;
94}
95#endif // THREADED_PIPELINE
96
97#ifdef THREADED_PIPELINE
98/**
99 * When called on the head of an empty list, takes all of the leemnts from the
100 * indicated list and moves them to this list.
101 */
102INLINE void PipelineCyclerLinks::
103take_list(PipelineCyclerLinks &other) {
104 nassertv(_next == this && _prev == this);
105 if (other._next == &other && other._prev == &other) {
106 // The other list is empty; this is a no-op.
107 return;
108 }
109
110 other._next->_prev = this;
111 other._prev->_next = this;
112 _next = other._next;
113 _prev = other._prev;
114
115 other._next = &other;
116 other._prev = &other;
117}
118#endif // THREADED_PIPELINE