Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 enum class EnqueueOrderValues { | |
|
Sami
2016/11/25 17:12:59
nit: enum class EnqueueOrderValues : EnqueueOrder
altimin
2016/11/25 17:44:09
Done.
| |
| 19 NONE = 0, | |
| 20 BLOCKING_FENCE = 1, | |
| 21 FIRST = 2, | |
| 22 }; | |
| 23 | |
| 18 // A 64bit integer used to provide ordering of tasks. NOTE The scheduler assumes | 24 // A 64bit integer used to provide ordering of tasks. NOTE The scheduler assumes |
| 19 // these values will not overflow. | 25 // these values will not overflow. |
| 20 class EnqueueOrderGenerator { | 26 class EnqueueOrderGenerator { |
| 21 public: | 27 public: |
| 22 EnqueueOrderGenerator(); | 28 EnqueueOrderGenerator(); |
| 23 ~EnqueueOrderGenerator(); | 29 ~EnqueueOrderGenerator(); |
| 24 | 30 |
| 25 // Returns a monotonically increasing integer, starting from one. Can be | 31 // Returns a monotonically increasing integer, starting from one. Can be |
| 26 // called from any thread. | 32 // called from any thread. |
| 27 EnqueueOrder GenerateNext(); | 33 EnqueueOrder GenerateNext(); |
| 28 | 34 |
| 29 static bool IsValidEnqueueOrder(EnqueueOrder enqueue_order) { | 35 static bool IsValidEnqueueOrder(EnqueueOrder enqueue_order) { |
| 30 return enqueue_order != 0ull; | 36 return enqueue_order != 0ull; |
| 31 } | 37 } |
| 32 | 38 |
| 33 private: | 39 private: |
| 34 base::Lock lock_; | 40 base::Lock lock_; |
| 35 EnqueueOrder enqueue_order_; | 41 EnqueueOrder enqueue_order_; |
| 36 }; | 42 }; |
| 37 | 43 |
| 38 } // namespace internal | 44 } // namespace internal |
| 39 } // namespace scheduler | 45 } // namespace scheduler |
| 40 } // namespace blink | 46 } // namespace blink |
| 41 | 47 |
| 42 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ | 48 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ |
| OLD | NEW |