| 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 // TODO(scheduler-dev): Remove explicit casts when c++17 comes. |
| 19 enum class EnqueueOrderValues : EnqueueOrder { |
| 20 // Invalid EnqueueOrder. |
| 21 NONE = 0, |
| 22 |
| 23 // Earliest possible EnqueueOrder, to be used for fence blocking. |
| 24 BLOCKING_FENCE = 1, |
| 25 FIRST = 2, |
| 26 }; |
| 27 |
| 18 // A 64bit integer used to provide ordering of tasks. NOTE The scheduler assumes | 28 // A 64bit integer used to provide ordering of tasks. NOTE The scheduler assumes |
| 19 // these values will not overflow. | 29 // these values will not overflow. |
| 20 class EnqueueOrderGenerator { | 30 class EnqueueOrderGenerator { |
| 21 public: | 31 public: |
| 22 EnqueueOrderGenerator(); | 32 EnqueueOrderGenerator(); |
| 23 ~EnqueueOrderGenerator(); | 33 ~EnqueueOrderGenerator(); |
| 24 | 34 |
| 25 // Returns a monotonically increasing integer, starting from one. Can be | 35 // Returns a monotonically increasing integer, starting from one. Can be |
| 26 // called from any thread. | 36 // called from any thread. |
| 27 EnqueueOrder GenerateNext(); | 37 EnqueueOrder GenerateNext(); |
| 28 | 38 |
| 29 static bool IsValidEnqueueOrder(EnqueueOrder enqueue_order) { | 39 static bool IsValidEnqueueOrder(EnqueueOrder enqueue_order) { |
| 30 return enqueue_order != 0ull; | 40 return enqueue_order != 0ull; |
| 31 } | 41 } |
| 32 | 42 |
| 33 private: | 43 private: |
| 34 base::Lock lock_; | 44 base::Lock lock_; |
| 35 EnqueueOrder enqueue_order_; | 45 EnqueueOrder enqueue_order_; |
| 36 }; | 46 }; |
| 37 | 47 |
| 38 } // namespace internal | 48 } // namespace internal |
| 39 } // namespace scheduler | 49 } // namespace scheduler |
| 40 } // namespace blink | 50 } // namespace blink |
| 41 | 51 |
| 42 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ | 52 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_ENQUEUE_ORDER_H_ |
| OLD | NEW |