1 /* Copyright (c) 2015-2016. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
17 /** Fulfill a promise by executing a given code */
18 template<class R, class F>
19 void fulfillPromise(std::promise<R>& promise, F code)
22 promise.set_value(code());
25 promise.set_exception(std::current_exception());
29 /** Fulfill a promise by executing a given code
31 * This is a special version for `std::promise<void>` because the default
32 * version does not compile in this case.
35 void fulfillPromise(std::promise<void>& promise, F code)
42 promise.set_exception(std::current_exception());