blob: 3e129289739a39703cd7f7e70cf8f61059a17ae0 [file] [log] [blame]
// Copyright 2010 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/allocation.h"
#include "src/base/atomicops.h"
namespace v8 {
namespace internal {
// Lock-free unbound queue for small records. Intended for
// transferring small records between a Single producer and a Single
// consumer. Doesn't have restrictions on the number of queued
// elements, so producer never blocks. Implemented after Herb
// Sutter's article:
template<typename Record>
class UnboundQueue BASE_EMBEDDED {
inline UnboundQueue();
inline ~UnboundQueue();
INLINE(bool Dequeue(Record* rec));
INLINE(void Enqueue(const Record& rec));
INLINE(bool IsEmpty() const);
INLINE(Record* Peek() const);
INLINE(void DeleteFirst());
struct Node;
Node* first_;
base::AtomicWord divider_; // Node*
base::AtomicWord last_; // Node*
} } // namespace v8::internal
#endif // V8_UNBOUND_QUEUE_