| 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 <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "include/v8-platform.h" | 10 #include "include/v8-platform.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class V8_EXPORT_PRIVATE CancelableTaskManager { | 25 class V8_EXPORT_PRIVATE CancelableTaskManager { |
| 26 public: | 26 public: |
| 27 CancelableTaskManager(); | 27 CancelableTaskManager(); |
| 28 | 28 |
| 29 // Registers a new cancelable {task}. Returns the unique {id} of the task that | 29 // Registers a new cancelable {task}. Returns the unique {id} of the task that |
| 30 // can be used to try to abort a task by calling {Abort}. | 30 // can be used to try to abort a task by calling {Abort}. |
| 31 // Must not be called after CancelAndWait. | 31 // Must not be called after CancelAndWait. |
| 32 uint32_t Register(Cancelable* task); | 32 uint32_t Register(Cancelable* task); |
| 33 | 33 |
| 34 // Try to abort running a task identified by {id}. The possible outcomes are: | 34 // Try to abort running a task identified by {id}. The possible outcomes are: |
| 35 // (1) The task is already finished running and thus has been removed from | 35 // (1) The task is already finished running or was canceled before and |
| 36 // the manager. | 36 // thus has been removed from the manager. |
| 37 // (2) The task is currently running and cannot be canceled anymore. | 37 // (2) The task is currently running and cannot be canceled anymore. |
| 38 // (3) The task is not yet running (or finished) so it is canceled and | 38 // (3) The task is not yet running (or finished) so it is canceled and |
| 39 // removed. | 39 // removed. |
| 40 // | 40 // |
| 41 // Returns {false} for (1) and (2), and {true} for (3). | 41 enum TryAbortResult { kTaskRemoved, kTaskRunning, kTaskAborted }; |
| 42 bool TryAbort(uint32_t id); | 42 TryAbortResult TryAbort(uint32_t id); |
| 43 | 43 |
| 44 // Cancels all remaining registered tasks and waits for tasks that are | 44 // Cancels all remaining registered tasks and waits for tasks that are |
| 45 // already running. This disallows subsequent Register calls. | 45 // already running. This disallows subsequent Register calls. |
| 46 void CancelAndWait(); | 46 void CancelAndWait(); |
| 47 | 47 |
| 48 private: | 48 private: |
| 49 // Only called by {Cancelable} destructor. The task is done with executing, | 49 // Only called by {Cancelable} destructor. The task is done with executing, |
| 50 // but needs to be removed. | 50 // but needs to be removed. |
| 51 void RemoveFinishedTask(uint32_t id); | 51 void RemoveFinishedTask(uint32_t id); |
| 52 | 52 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 private: | 163 private: |
| 164 Isolate* isolate_; | 164 Isolate* isolate_; |
| 165 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); | 165 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 | 168 |
| 169 } // namespace internal | 169 } // namespace internal |
| 170 } // namespace v8 | 170 } // namespace v8 |
| 171 | 171 |
| 172 #endif // V8_CANCELABLE_TASK_H_ | 172 #endif // V8_CANCELABLE_TASK_H_ |
| OLD | NEW |