| 130 | typename CF = typename internal::unwrap<typename result_of<Body(T)>::type>::type, // NOLINT(whitespace/line_length) |
| 131 | typename V = typename CF::ValueType> |
| 132 | Future<V> loop(Iterate&& iterate, Body&& body) |
| 133 | { |
| 134 | // Have libprocess own and free the new `ProcessBase`. |
| 135 | UPID process = spawn(new ProcessBase(), true); |
| 136 | |
| 137 | return loop<Iterate, Body, T, CF, V>( |
| 138 | process, |
| 139 | std::forward<Iterate>(iterate), |
| 140 | std::forward<Body>(body)) |
| 141 | .onAny([=]() { |
| 142 | terminate(process); |
| 143 | // NOTE: no need to `wait` or `delete` since the `spawn` above |
| 144 | // put libprocess in control of garbage collection. |
| 145 | }); |
| 146 | } |
| 147 | |
| 148 | |
| 149 | // Generic "control flow" construct that is leveraged by |