13 #ifndef __PROCESS_SEQUENCE_HPP__
14 #define __PROCESS_SEQUENCE_HPP__
16 #include <glog/logging.h>
29 class SequenceProcess;
36 Sequence(
const std::string&
id =
"sequence");
104 promise->future().onAny(
lambda::bind(&completed, notifier));
116 notifier->future().onDiscard(
118 &internal::discard<T>,
122 notifier->future().onDiscard(
124 &internal::discard<Nothing>,
128 last = notifier->future();
130 return promise->future();
150 template <
typename T>
151 static void notified(
153 const lambda::function<Future<T>()>& callback)
155 if (
promise->future().hasDiscard()) {
161 promise->associate(callback());
165 Future<Nothing> last;
184 template <
typename T>
187 return dispatch(process, &SequenceProcess::add<T>, callback);
192 #endif // __PROCESS_SEQUENCE_HPP__
std::string generate(const std::string &prefix="")
Returns 'prefix(N)' where N represents the number of instances where the same prefix (wrt...
Definition: nothing.hpp:16
Definition: sequence.hpp:63
Future< T > add(const lambda::function< Future< T >()> &callback)
Definition: sequence.hpp:71
Future< T > add(const lambda::function< Future< T >()> &callback)
Definition: sequence.hpp:185
Definition: process.hpp:72
bool discard()
Definition: future.hpp:1173
~Sequence()
Definition: sequence.hpp:176
UPID spawn(ProcessBase *process, bool manage=false)
Spawn a new process.
void terminate(const UPID &pid, bool inject=true)
Sends a TerminateEvent to the given process.
Definition: sequence.hpp:33
void dispatch(const PID< T > &pid, void(T::*method)())
Definition: dispatch.hpp:174
virtual void finalize()
Invoked when a process is terminated.
Definition: sequence.hpp:134
const Future< T > & onAny(AnyCallback &&callback) const
Definition: future.hpp:1458
Protocol< PromiseRequest, PromiseResponse > promise
Definition: future.hpp:78
bool wait(const UPID &pid, const Duration &duration=Seconds(-1))
Wait for the process to exit for no more than the specified seconds.
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
SequenceProcess(const std::string &id)
Definition: sequence.hpp:66
Try< Nothing > bind(int_fd s, const Address &address)
Definition: network.hpp:46
Definition: process.hpp:493
Sequence(const std::string &id="sequence")
Definition: sequence.hpp:169
Definition: future.hpp:57