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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h

Issue 2258713004: Make tasks cancellable inside the blink scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Various comment nits addressed Created 4 years, 4 months 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 | third_party/WebKit/Source/platform/scheduler/base/enqueue_order.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
11 11
12 namespace blink { 12 namespace blink {
13 namespace scheduler { 13 namespace scheduler {
14 namespace internal { 14 namespace internal {
15 15
16 using EnqueueOrder = uint64_t; 16 using EnqueueOrder = uint64_t;
17 17
18 // A 64bit integer used to provide ordering of tasks. NOTE The scheduler assumes
19 // these values will not overflow.
18 class EnqueueOrderGenerator { 20 class EnqueueOrderGenerator {
19 public: 21 public:
20 EnqueueOrderGenerator(); 22 EnqueueOrderGenerator();
21 ~EnqueueOrderGenerator(); 23 ~EnqueueOrderGenerator();
22 24
25 // Returns a monotonically increasing integer, starting from one. Can be
26 // called from any thread.
23 EnqueueOrder GenerateNext(); 27 EnqueueOrder GenerateNext();
24 28
29 static bool IsValidEnqueueOrder(EnqueueOrder enqueue_order) {
30 return enqueue_order != 0ull;
31 }
32
25 private: 33 private:
26 base::Lock lock_; 34 base::Lock lock_;
27 EnqueueOrder enqueue_order_; 35 EnqueueOrder enqueue_order_;
28 }; 36 };
29 37
30 } // namespace internal 38 } // namespace internal
31 } // namespace scheduler 39 } // namespace scheduler
32 } // namespace blink 40 } // namespace blink
33 41
34 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ 42 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/base/enqueue_order.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698