OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef BASE_SERIAL_EXECUTOR_H_ | |
6 #define BASE_SERIAL_EXECUTOR_H_ | |
7 #pragma once | |
8 | |
9 #include "base/base_export.h" | |
10 #include "base/executor.h" | |
11 | |
12 namespace base { | |
13 | |
14 // A SerialExecutor is an Executor with more guarantees. In | |
15 // particular: | |
16 // | |
17 // - Given two tasks T1 and T2 that are posted from the same thread, | |
18 // T2 will be executed after T1 iff: | |
brettw
2012/02/03 22:42:15
Just write "if". "iff" is a non-word jumps out and
| |
19 // | |
20 // * T2 is posted after T1; | |
21 // * T2 has equal or higher delay than T1; and | |
22 // * T1 is nestable, or T1 and T2 are both non-nestable. | |
23 // | |
24 // - If task T2 is executed after T1, then all memory changes in T1 | |
25 // will be visible to T1. | |
26 // | |
27 // Note that SerialExecutor does not guarantee execution on a single | |
28 // thread (see SingleThreadExecutor instead). | |
29 // | |
30 // Some corollaries to the above guarantees, in order of increasing | |
brettw
2012/02/03 22:42:15
Does "in order of increasing generality" help anyt
| |
31 // generality: | |
32 // | |
33 // - Tasks submitted via PostTask are executed in FIFO order. | |
34 // | |
35 // - Tasks submitted via PostNonNestableTask are executed in FIFO | |
36 // order. | |
37 // | |
38 // - Tasks submitted with the same delay and the same nestable state | |
39 // are executed in FIFO order. | |
40 // | |
41 // - A list of tasks with the same nestable state submitted in order | |
42 // of non-decreasing delay is executed in FIFO order. | |
43 // | |
44 // - A list of tasks submitted in order of non-decreasing delay with | |
45 // at most a single change in nestable state from nestable to | |
46 // non-nestable is executed in FIFO order. (This is equivalent to | |
47 // the statement of the first guarantee above.) | |
48 // | |
49 // Some theoretical implementations of SerialExecutor: | |
50 // | |
51 // - A SerialExecutor that wraps a regular Executor but makes sure | |
52 // that only one task at a time is posted to the Executor, with | |
53 // appropriate memory barriers in between tasks. | |
54 // | |
55 // - A SerialExecutor that, for each task, spawns a joinable thread | |
56 // to execute that task and immediately quit, and then immediately | |
57 // joins that thread. | |
58 // | |
59 // - A SerialExecutor that stores the list of submitted tasks and | |
60 // has a method Run() that executes each runnable task in FIFO | |
61 // order that can be called from any thread, but only if another | |
62 // (non-nested) Run() call isn't already happening. | |
63 class BASE_EXPORT SerialExecutor : public Executor { | |
64 }; | |
65 | |
66 } // namespace base | |
67 | |
68 #endif // BASE_SERIAL_EXECUTOR_H_ | |
OLD | NEW |