Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(270)

Side by Side Diff: src/cancelable-task.h

Issue 2413203004: [heap] Cancel tasks before tearing down the heap. (Closed)
Patch Set: cancel new tasks Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/cancelable-task.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 22 matching lines...) Expand all
33 // (1) The task is already finished running and thus has been removed from 33 // (1) The task is already finished running and thus has been removed from
34 // the manager. 34 // the manager.
35 // (2) The task is currently running and cannot be canceled anymore. 35 // (2) The task is currently running and cannot be canceled anymore.
36 // (3) The task is not yet running (or finished) so it is canceled and 36 // (3) The task is not yet running (or finished) so it is canceled and
37 // removed. 37 // removed.
38 // 38 //
39 // Returns {false} for (1) and (2), and {true} for (3). 39 // Returns {false} for (1) and (2), and {true} for (3).
40 bool TryAbort(uint32_t id); 40 bool TryAbort(uint32_t id);
41 41
42 // Cancels all remaining registered tasks and waits for tasks that are 42 // Cancels all remaining registered tasks and waits for tasks that are
43 // already running. 43 // already running. After this function is called all subsequent new tasks
44 // will be cancelled on creation.
44 void CancelAndWait(); 45 void CancelAndWait();
45 46
46 private: 47 private:
47 // Only called by {Cancelable} destructor. The task is done with executing, 48 // Only called by {Cancelable} destructor. The task is done with executing,
48 // but needs to be removed. 49 // but needs to be removed.
49 void RemoveFinishedTask(uint32_t id); 50 void RemoveFinishedTask(uint32_t id);
50 51
51 // To mitigate the ABA problem, the api refers to tasks through an id. 52 // To mitigate the ABA problem, the api refers to tasks through an id.
52 uint32_t task_id_counter_; 53 uint32_t task_id_counter_;
53 54
54 // A set of cancelable tasks that are currently registered. 55 // A set of cancelable tasks that are currently registered.
55 std::map<uint32_t, Cancelable*> cancelable_tasks_; 56 std::map<uint32_t, Cancelable*> cancelable_tasks_;
56 57
57 // Mutex and condition variable enabling concurrent register and removing, as 58 // Mutex and condition variable enabling concurrent register and removing, as
58 // well as waiting for background tasks on {CancelAndWait}. 59 // well as waiting for background tasks on {CancelAndWait}.
59 base::ConditionVariable cancelable_tasks_barrier_; 60 base::ConditionVariable cancelable_tasks_barrier_;
60 base::Mutex mutex_; 61 base::Mutex mutex_;
61 62
63 bool canceled_;
64
62 friend class Cancelable; 65 friend class Cancelable;
63 66
64 DISALLOW_COPY_AND_ASSIGN(CancelableTaskManager); 67 DISALLOW_COPY_AND_ASSIGN(CancelableTaskManager);
65 }; 68 };
66 69
67 70
68 class Cancelable { 71 class Cancelable {
69 public: 72 public:
70 explicit Cancelable(CancelableTaskManager* parent); 73 explicit Cancelable(CancelableTaskManager* parent);
71 virtual ~Cancelable(); 74 virtual ~Cancelable();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 private: 163 private:
161 Isolate* isolate_; 164 Isolate* isolate_;
162 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask); 165 DISALLOW_COPY_AND_ASSIGN(CancelableIdleTask);
163 }; 166 };
164 167
165 168
166 } // namespace internal 169 } // namespace internal
167 } // namespace v8 170 } // namespace v8
168 171
169 #endif // V8_CANCELABLE_TASK_H_ 172 #endif // V8_CANCELABLE_TASK_H_
OLDNEW
« no previous file with comments | « no previous file | src/cancelable-task.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698