xhawk18
xhawk18
> 建议判断下是不是C++17,是的话就用std::any,不是的话再用pm_any吧 > 或者 using pm_any = std::any 类似这样 还有tuple,应该也可以改用标准库的。 主要原因是any/tuple涉及到一点类型推导,resolve/reject填入的参数要被后面的then匹配的函数抓到,匹配函数类型这里定制了一些 any/tuple的内容,我有些迁移不动,太复杂。
确实!是没有支持
Hi, shtaif, thank you for liking this library. multiple then is not suppored currently. We can use the below code as a workaround -- ``` Defer p = promise::resolve(); p.then([](){...
> @xhawk18 恕我愚钝,这两个写法不是等价的吗?看起来是一样的鸭! shtaif的写法原本也可以支持的。基于一点微妙的原因,没有支持 --- promise对象实际上可以包含任意类型的数据,以便交给下一级then调用。 如下的例子里,包含了一个 std::shared_ptr 类型的数据data。 ``` Defer p = promise::resolve().then([](){ std::shared_ptr data = std::make_shared(); *data = 3; return data; }); ```` data何时被释放,有两个实现方法: 方法一:p对象被析构时,再释放。 方法二:调用p对象的下一级then时释放。 目前使用方法二,该方法不能达到shtaif要求的效果 --...
The bug was fixed in the latest version, (please use promise::Promise instead of promise::Defer as the return type) ``` promise::Promise p = promise::resolve(); p.then([]() { std::cout
Hi, because we allocate Defer object on thread_local memory, please check if the thread that calls newPromise(...) keeps alived before the promise object has been destroyed.
thank you, there must be some problem if "resolve" thread terminated. i'll check this issue.
已修正,多谢指出 https://github.com/xhawk18/promise-cpp/commit/f8db3ad10091e4d1a951c0c52f35f0338374cdc0
> @xhawk18 If you create a new release of this library which includes this fix, I can add this library to [vcpkg](https://vcpkg.io/en/index.html). thank you, created new release here https://github.com/xhawk18/promise-cpp/releases/tag/1.0.3
没想过这么做呢