#ifndef SRC_CALLBACK_QUEUE_INL_H_
#define SRC_CALLBACK_QUEUE_INL_H_
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "callback_queue.h"
namespace node {
template
template
std::unique_ptr::Callback>
CallbackQueue::CreateCallback(Fn&& fn, CallbackFlags::Flags flags) {
return std::make_unique>(std::move(fn), flags);
}
template
std::unique_ptr::Callback>
CallbackQueue::Shift() {
std::unique_ptr ret = std::move(head_);
if (ret) {
head_ = ret->get_next();
if (!head_)
tail_ = nullptr; // The queue is now empty.
size_--;
}
return ret;
}
template
void CallbackQueue::Push(std::unique_ptr cb) {
Callback* prev_tail = tail_;
size_++;
tail_ = cb.get();
if (prev_tail != nullptr)
prev_tail->set_next(std::move(cb));
else
head_ = std::move(cb);
}
template
void CallbackQueue::ConcatMove(CallbackQueue&& other) {
size_ += other.size_;
if (tail_ != nullptr)
tail_->set_next(std::move(other.head_));
else
head_ = std::move(other.head_);
tail_ = other.tail_;
other.tail_ = nullptr;
other.size_ = 0;
}
template
size_t CallbackQueue::size() const {
return size_.load();
}
template
CallbackQueue::Callback::Callback(CallbackFlags::Flags flags)
: flags_(flags) {}
template
CallbackFlags::Flags CallbackQueue::Callback::flags() const {
return flags_;
}
template
std::unique_ptr::Callback>
CallbackQueue::Callback::get_next() {
return std::move(next_);
}
template
void CallbackQueue::Callback::set_next(
std::unique_ptr next) {
next_ = std::move(next);
}
template
template
CallbackQueue::CallbackImpl::CallbackImpl(
Fn&& callback, CallbackFlags::Flags flags)
: Callback(flags),
callback_(std::move(callback)) {}
template
template
R CallbackQueue::CallbackImpl::Call(Args... args) {
return callback_(std::forward(args)...);
}
} // namespace node
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#endif // SRC_CALLBACK_QUEUE_INL_H_