Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Side by Side Diff: src/locked-queue.h

Issue 1448283004: Add lock-based unbounded queue (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moved to atomic handling for Node.next Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/locked-queue-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef V8_LOCKED_QUEUE_
6 #define V8_LOCKED_QUEUE_
7
8 #include "src/allocation.h"
9 #include "src/base/platform/platform.h"
10
11 namespace v8 {
12 namespace internal {
13
14 // Simple lock-based unbounded size queue (multi producer; multi consumer) based
15 // on "Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue
16 // Algorithms" by M. Scott and M. Michael.
17 // See:
18 // https://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html
19 template <typename Record>
20 class LockedQueue final BASE_EMBEDDED {
21 public:
22 inline LockedQueue();
23 inline ~LockedQueue();
24 inline void Enqueue(const Record& record);
25 inline bool Dequeue(Record* record);
26 inline bool IsEmpty() const;
27 inline bool Peek(Record* record) const;
28
29 private:
30 struct Node;
31
32 mutable base::Mutex head_mutex_;
33 base::Mutex tail_mutex_;
34 Node* head_;
35 Node* tail_;
36
37 DISALLOW_COPY_AND_ASSIGN(LockedQueue);
38 };
39
40 } // namespace internal
41 } // namespace v8
42
43 #endif // V8_LOCKED_QUEUE_
OLDNEW
« no previous file with comments | « no previous file | src/locked-queue-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698