| 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 // 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_ |
| OLD | NEW |