The test verifies that callbacks are properly serialized by the Sequence object.
| 66 | // The test verifies that callbacks are properly serialized by the |
| 67 | // Sequence object. |
| 68 | TEST(SequenceTest, Serialize) |
| 69 | { |
| 70 | TestProcess process; |
| 71 | spawn(process); |
| 72 | |
| 73 | Sequence sequence; |
| 74 | |
| 75 | Future<Nothing> bar = FUTURE_DISPATCH(_, &TestProcess::bar); |
| 76 | |
| 77 | lambda::function<Future<Nothing>()> f; |
| 78 | |
| 79 | f = defer(process, &TestProcess::foo); |
| 80 | sequence.add(f); |
| 81 | |
| 82 | f = defer(process, &TestProcess::bar); |
| 83 | sequence.add(f); |
| 84 | |
| 85 | // Flush the event queue to make sure that if the method 'bar' could |
| 86 | // have been invoked, the future 'bar' would be satisfied before the |
| 87 | // pending check below. |
| 88 | Clock::pause(); |
| 89 | Clock::settle(); |
| 90 | Clock::resume(); |
| 91 | |
| 92 | EXPECT_TRUE(bar.isPending()); |
| 93 | |
| 94 | process.promise.set(Nothing()); |
| 95 | |
| 96 | AWAIT_READY(bar); |
| 97 | |
| 98 | terminate(process); |
| 99 | wait(process); |
| 100 | } |
| 101 | |
| 102 | |
| 103 | // Used to verify the discard semantics of Sequence. |