| 6 |
| 7 | #include <utility> |
| 8 |
| 9 | #include "base/atomic_sequence_num.h" |
| 10 |
| 11 | namespace base { |
| 12 | namespace internal { |
| 13 |
| 14 | namespace { |
| 15 |
| 16 | AtomicSequenceNumber g_sequence_nums_for_tracing; |
| 17 |
| 18 | } // namespace |
| 19 |
| 20 | Task::Task() = default; |
| 21 |
| 22 | Task::Task(const Location& posted_from, OnceClosure task, TimeDelta delay) |
| 23 | : PendingTask(posted_from, |
| 24 | std::move(task), |
| 25 | delay.is_zero() ? TimeTicks() : TimeTicks::Now() + delay, |
| 26 | Nestable::kNonNestable) { |
| 27 | // ThreadPoolImpl doesn't use |sequence_num| but tracing (toplevel.flow) |
| 28 | // relies on it being unique. While this subtle dependency is a bit |
| 29 | // overreaching, ThreadPoolImpl is the only task system that doesn't use |
| 30 | // |sequence_num| and the dependent code rarely changes so this isn't worth a |
| 31 | // big change and faking it here isn't too bad for now (posting tasks is full |
| 32 | // of atomic ops already). |
| 33 | this->sequence_num = g_sequence_nums_for_tracing.GetNext(); |
| 34 | } |
| 35 |
| 36 | // This should be "= default but MSVC has trouble with "noexcept = default" in |
| 37 | // this case. |
| 38 | Task::Task(Task&& other) noexcept : PendingTask(std::move(other)) {} |
| 39 |
| 40 | Task::~Task() = default; |
| 41 |
| 42 | Task& Task::operator=(Task&& other) = default; |
| 43 |
| 44 | } // namespace internal |
| 45 | } // namespace base |
| 46 |