timeoutError that takes Future<Error<T>> as input
This commit is contained in:
parent
7ec8fe6e74
commit
806a0822f1
|
@ -198,7 +198,21 @@ Future<T> timeoutError( Future<T> what, double time, TaskPriority taskID = TaskP
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
ACTOR template <class T>
|
||||
Future<T> timeoutError( Future<ErrorOr<T>> what, double time, TaskPriority taskID = TaskPriority::DefaultDelay ) {
|
||||
Future<Void> end = delay( time, taskID );
|
||||
choose {
|
||||
when( ErrorOr<T> t = wait( what ) ) {
|
||||
if (t.isError()) {
|
||||
throw t.getError();
|
||||
}
|
||||
return t.get();
|
||||
}
|
||||
when( wait( end ) ) { throw timed_out(); }
|
||||
}
|
||||
}
|
||||
|
||||
Future<T> delayed( Future<T> what, double time = 0.0, TaskPriority taskID = TaskPriority::DefaultDelay ) {
|
||||
try {
|
||||
state T t = wait( what );
|
||||
|
|
Loading…
Reference in New Issue