Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/nodejs/src/callback_queue-inl.h
$ cat -n /usr/include/nodejs/src/callback_queue-inl.h 1 #ifndef SRC_CALLBACK_QUEUE_INL_H_ 2 #define SRC_CALLBACK_QUEUE_INL_H_ 3 4 #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 5 6 #include "callback_queue.h" 7 8 namespace node { 9 10 template
11 template
12 std::unique_ptr
::Callback> 13 CallbackQueue
::CreateCallback(Fn&& fn, CallbackFlags::Flags flags) { 14 return std::make_unique
>(std::move(fn), flags); 15 } 16 17 template
18 std::unique_ptr
::Callback> 19 CallbackQueue
::Shift() { 20 std::unique_ptr
ret = std::move(head_); 21 if (ret) { 22 head_ = ret->get_next(); 23 if (!head_) 24 tail_ = nullptr; // The queue is now empty. 25 size_--; 26 } 27 return ret; 28 } 29 30 template
31 void CallbackQueue
::Push(std::unique_ptr
cb) { 32 Callback* prev_tail = tail_; 33 34 size_++; 35 tail_ = cb.get(); 36 if (prev_tail != nullptr) 37 prev_tail->set_next(std::move(cb)); 38 else 39 head_ = std::move(cb); 40 } 41 42 template
43 void CallbackQueue
::ConcatMove(CallbackQueue
&& other) { 44 size_ += other.size_; 45 if (tail_ != nullptr) 46 tail_->set_next(std::move(other.head_)); 47 else 48 head_ = std::move(other.head_); 49 tail_ = other.tail_; 50 other.tail_ = nullptr; 51 other.size_ = 0; 52 } 53 54 template
55 size_t CallbackQueue
::size() const { 56 return size_.load(); 57 } 58 59 template
60 CallbackQueue
::Callback::Callback(CallbackFlags::Flags flags) 61 : flags_(flags) {} 62 63 template
64 CallbackFlags::Flags CallbackQueue
::Callback::flags() const { 65 return flags_; 66 } 67 68 template
69 std::unique_ptr
::Callback> 70 CallbackQueue
::Callback::get_next() { 71 return std::move(next_); 72 } 73 74 template
75 void CallbackQueue
::Callback::set_next( 76 std::unique_ptr
next) { 77 next_ = std::move(next); 78 } 79 80 template
81 template
82 CallbackQueue
::CallbackImpl
::CallbackImpl( 83 Fn&& callback, CallbackFlags::Flags flags) 84 : Callback(flags), 85 callback_(std::move(callback)) {} 86 87 template
88 template
89 R CallbackQueue
::CallbackImpl
::Call(Args... args) { 90 return callback_(std::forward
(args)...); 91 } 92 93 } // namespace node 94 95 #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS 96 97 #endif // SRC_CALLBACK_QUEUE_INL_H_
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™