OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 /* | 59 /* |
60 * Utility function uses type inference to simplify expressions at point of us
e. | 60 * Utility function uses type inference to simplify expressions at point of us
e. |
61 */ | 61 */ |
62 template<class T> | 62 template<class T> |
63 HeapFunction<T> MakeHeapFunction(std::shared_ptr<T> body) | 63 HeapFunction<T> MakeHeapFunction(std::shared_ptr<T> body) |
64 { | 64 { |
65 return HeapFunction<T>(body); | 65 return HeapFunction<T>(body); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 /* | 69 /** |
| 70 * Interface class for scheduled tasks. |
| 71 */ |
| 72 struct TaskFunctionInterface |
| 73 { |
| 74 /** |
| 75 * The main function of the task, |
| 76 * the moral equivalent to the main function of the thread. |
| 77 */ |
| 78 virtual void operator()() = 0; |
| 79 /** |
| 80 * Request that the task end itself early, without needing to complete. |
| 81 * Reserved for future use. |
| 82 */ |
| 83 virtual void Interrupt() {}; |
| 84 }; |
| 85 |
| 86 /** |
70 * Execute a task immediately in detached thread that's used only for this task. | 87 * Execute a task immediately in detached thread that's used only for this task. |
71 * | 88 * |
72 * The present version is nothing more than a rewrite of the legacy behavior, | 89 * The present version is nothing more than a rewrite of the legacy behavior, |
73 * which was to create a new thread for each task. | 90 * which was to create a new thread for each task. |
74 */ | 91 */ |
75 void StartImmediatelyInSingleUseDetachedThread(std::function<void()> task); | 92 void StartImmediatelyInSingleUseDetachedThread(std::function<void()> task); |
76 | 93 |
77 /** | 94 /** |
78 * Active object to run arbitrary function objects. | 95 * Active object to run arbitrary function objects. |
79 * | 96 * |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 { | 287 { |
271 // The call to `Worker::Join()` is in another function, | 288 // The call to `Worker::Join()` is in another function, |
272 // namely `JoinAndRemove()`, which also removes items from the task list. | 289 // namely `JoinAndRemove()`, which also removes items from the task list. |
273 // Thus all we do here is to wait for the task list to empty. | 290 // Thus all we do here is to wait for the task list to empty. |
274 UniqueLockType ul(m); | 291 UniqueLockType ul(m); |
275 taskRemoveCv.wait(ul, [this]() -> bool { return taskList.empty(); }); | 292 taskRemoveCv.wait(ul, [this]() -> bool { return taskList.empty(); }); |
276 } | 293 } |
277 }; | 294 }; |
278 | 295 |
279 #endif | 296 #endif |
OLD | NEW |