| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 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 | 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 V8_CANCELABLE_TASK_H_ | 5 #ifndef V8_CANCELABLE_TASK_H_ |
| 6 #define V8_CANCELABLE_TASK_H_ | 6 #define V8_CANCELABLE_TASK_H_ |
| 7 | 7 |
| 8 #include "include/v8-platform.h" | 8 #include "include/v8-platform.h" |
| 9 #include "src/atomic-utils.h" | 9 #include "src/base/atomic-utils.h" |
| 10 #include "src/base/macros.h" | 10 #include "src/base/macros.h" |
| 11 #include "src/base/platform/condition-variable.h" | 11 #include "src/base/platform/condition-variable.h" |
| 12 #include "src/hashmap.h" | 12 #include "src/hashmap.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 class Cancelable; | 17 class Cancelable; |
| 18 class Isolate; | 18 class Isolate; |
| 19 | 19 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // executed. | 97 // executed. |
| 98 bool Cancel() { | 98 bool Cancel() { |
| 99 if (status_.TrySetValue(kWaiting, kCanceled)) { | 99 if (status_.TrySetValue(kWaiting, kCanceled)) { |
| 100 return true; | 100 return true; |
| 101 } | 101 } |
| 102 cancel_counter_.Increment(1); | 102 cancel_counter_.Increment(1); |
| 103 return false; | 103 return false; |
| 104 } | 104 } |
| 105 | 105 |
| 106 CancelableTaskManager* parent_; | 106 CancelableTaskManager* parent_; |
| 107 AtomicValue<Status> status_; | 107 base::AtomicValue<Status> status_; |
| 108 uint32_t id_; | 108 uint32_t id_; |
| 109 | 109 |
| 110 // The counter is incremented for failing tries to cancel a task. This can be | 110 // The counter is incremented for failing tries to cancel a task. This can be |
| 111 // used by the task itself as an indication how often external entities tried | 111 // used by the task itself as an indication how often external entities tried |
| 112 // to abort it. | 112 // to abort it. |
| 113 AtomicNumber<intptr_t> cancel_counter_; | 113 base::AtomicNumber<intptr_t> cancel_counter_; |
| 114 | 114 |
| 115 friend class CancelableTaskManager; | 115 friend class CancelableTaskManager; |
| 116 | 116 |
| 117 DISALLOW_COPY_AND_ASSIGN(Cancelable); | 117 DISALLOW_COPY_AND_ASSIGN(Cancelable); |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 | 120 |
| 121 // Multiple inheritance can be used because Task is a pure interface. | 121 // Multiple inheritance can be used because Task is a pure interface. |
| 122 class CancelableTask : public Cancelable, public Task { | 122 class CancelableTask : public Cancelable, public Task { |
| 123 public: | 123 public: |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 private: | 159 private: |
| 160 Isolate* isolate_; | 160 Isolate* isolate_; |
| 161 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); | 161 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 | 164 |
| 165 } // namespace internal | 165 } // namespace internal |
| 166 } // namespace v8 | 166 } // namespace v8 |
| 167 | 167 |
| 168 #endif // V8_CANCELABLE_TASK_H_ | 168 #endif // V8_CANCELABLE_TASK_H_ |
| OLD | NEW |