Commit Graph

53 Commits

Author SHA1 Message Date
Simon Brunel
596855f579 Move helpers in separate file and add unit tests
Gather helpers in `promisehelpers.h` and add a global include file to make easier integration with the lib (`#include <QtPromise>`).
2017-05-25 09:19:36 +02:00
Simon Brunel
ce3ed72dd4 Promise creation from callback only (resolver)
Make sure that the promise state can only be changed by the promise producer (and not consumers) by removing the `fulfill` and `reject` methods from the instance members and introducing a new constructor accepting a resolver lambda. That also means that a promise can't anymore be default constructed.

Add the static `QPromise<T>::resolve` and `QPromise<T>::reject` methods to create synchronously fulfilled or rejected promises, and fix the `qPromise` helper to handle deduced promises (e.g. `qPromise(QFuture<int>()) -> QPromise<int>`).
2017-05-20 09:40:42 +02:00
Simon Brunel
6a642446df Initial implementation 2017-05-14 19:03:01 +02:00