Ejemplo n.º 1
0
void FontFaceSet::completedLoading()
{
    if (m_promise)
        fulfillPromise();
    m_promise = Nullopt;
    // FIXME: Fire a "loadingdone" and possibly a "loadingerror" event asynchronously.
}
Ejemplo n.º 2
0
/** Set a promise/result from a future/result
 *
 *  Roughly this does:
 *
 *  <pre>promise.set_value(future);</pre>
 *
 *  but it takes care of exceptions and works with `void`.
 *
 *  We might need this when working with generic code because
 *  the trivial implementation does not work with `void` (before C++1z).
 *
 *  @param promise output (a valid future or a result)
 *  @param future  input (a ready/waitable future or a valid result)
 */
template<class P, class F> inline
void setPromise(P& promise, F&& future)
{
  fulfillPromise(promise, [&]{ return std::forward<F>(future).get(); });
}