Modified future behaviour when completing with an exception.

Futures will now raise the exception if they did not have a callback
associated with them.
This commit is contained in:
Dominik Picheta
2014-05-24 15:51:41 +01:00
parent b386d38208
commit d54b902441

View File

@@ -71,6 +71,11 @@ proc fail*[T](future: PFuture[T], error: ref EBase) =
future.error = error
if future.cb != nil:
future.cb()
else:
# This is to prevent exceptions from being silently ignored when a future
# is discarded.
# TODO: This may turn out to be a bad idea.
raise error
proc `callback=`*(future: PFutureBase, cb: proc () {.closure,gcsafe.}) =
## Sets the callback proc to be called when the future completes.