Commit Graph

7 Commits

Author SHA1 Message Date
Simon Brunel
931d5d5b13 Fix MSVC 2013 compilation issues 2017-09-04 11:17:26 +02:00
Simon Brunel
c55fa03e7b Implement QPromise::tap(handler)
This `handler` allows to observe the value of the `input` promise, without changing the propagated value. The `output` promise will be resolved with the same value as the `input` promise (the `handler` returned value will be ignored). However, if `handler` throws, `output` is rejected with the new exception. Unlike `finally`, this handler is not called for rejections.
2017-08-23 21:06:59 +02:00
Simon Brunel
25d2bad54f Enhance QPromise::finally implementation
Make sure that the chained value is not copied when `finally` is called for a fulfilled input promise. The value was copied 7 times in the previous version because it was captured in a lambda, which one copied multiple times.
2017-08-23 10:59:44 +02:00
Simon Brunel
49a1d6a57b Avoid value copy when fulfilled from promise 2017-08-22 21:52:28 +02:00
Simon Brunel
5e754d1b08 Minor code style cleanup 2017-06-10 10:06:25 +02:00
Simon Brunel
81625e1964 Add multithreading support
Make QPromise thread safe but also ensure that continuation lambdas (then/fail/finally) are called in the thread of the promise instance they are attached to.
2017-06-04 22:22:26 +02:00
Simon Brunel
9bbef41a50 C++11 optimizations and (basic) benchmark
Make continuation methods const (then/fail/finally) and ensure that the resolved promise value/error is copied only when required, same for user lambdas (dispatching result is now fully handled by the PromiseData).
2017-06-03 10:04:28 +02:00