5 #ifndef V8_LOCKED_QUEUE_INL_H_ 6 #define V8_LOCKED_QUEUE_INL_H_ 8 #include "src/base/atomic-utils.h" 9 #include "src/locked-queue.h" 14 template <
typename Record>
16 Node() : next(
nullptr) {}
22 template <
typename Record>
25 CHECK_NOT_NULL(head_);
30 template <
typename Record>
33 Node* old_node =
nullptr;
34 Node* cur_node = head_;
35 while (cur_node !=
nullptr) {
37 cur_node = cur_node->next.Value();
43 template <
typename Record>
44 inline void LockedQueue<Record>::Enqueue(
const Record& record) {
49 base::MutexGuard guard(&tail_mutex_);
50 tail_->next.SetValue(n);
56 template <
typename Record>
57 inline bool LockedQueue<Record>::Dequeue(Record* record) {
58 Node* old_head =
nullptr;
60 base::MutexGuard guard(&head_mutex_);
62 Node*
const next_node = head_->next.Value();
63 if (next_node ==
nullptr)
return false;
64 *record = next_node->value;
72 template <
typename Record>
73 inline bool LockedQueue<Record>::IsEmpty()
const {
74 base::MutexGuard guard(&head_mutex_);
75 return head_->next.Value() ==
nullptr;
79 template <
typename Record>
80 inline bool LockedQueue<Record>::Peek(Record* record)
const {
81 base::MutexGuard guard(&head_mutex_);
82 Node*
const next_node = head_->next.Value();
83 if (next_node ==
nullptr)
return false;
84 *record = next_node->value;
91 #endif // V8_LOCKED_QUEUE_INL_H_