We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
使用task action,写一个自定义的action 类 class ThenTaskAction1 { public: ThenTaskAction1(){}
int operator()(void*) { return 0; }
private: };
然后调用copp_task的then方法: using simple_task_t = cotask::task<>; auto co_task = simple_task_t::create( { }); if (nullptr != co_task) { co_task->start(); //auto then_ptr1 = co_task->then(ThenTaskAction1()); // build OK
ThenTaskAction1 tmp; auto then_ptr2 = co_task->then(tmp); // 错误: ThenTaskAction1没有operator()成员 } else printf("error create coroutine %d\n", i);
我这边跟踪了一下原因是后面一种调用在模板参数类型是ThenTaskAction1&, 然而前者解释模板参数类型是ThenTaskAction1 于是我这边的解决方式是 在task_actions.h:91行改成 virtual int operator()(void *priv_data) { return detail::task_action_functor_check::call(&std::remove_reference<value_type>::type::operator(), functor_, priv_data); } 去掉了引用
看一下大神有什么好的解决方式或者有什么见解
The text was updated successfully, but these errors were encountered:
@aengusjiang 感谢反馈。这里确实是有个问题。开启右值的分支里对类型的推断不支持非右值。
这里建议action传入的时候move一下,否则即便修复了也是会拷贝构造来复制对象,可能会开销高。最初让这种情况编译不过是为了防止不小心使用了高开销的操作。
不过这确实导致两个分支的代码不能无缝切换,我明天处理下这个适配。需要修改构造流程,否则生命周期的维护有问题。
Sorry, something went wrong.
@aengusjiang Fixed in 1.3.2
owent
No branches or pull requests
使用task action,写一个自定义的action 类
class ThenTaskAction1
{
public:
ThenTaskAction1(){}
private:
};
然后调用copp_task的then方法:
using simple_task_t = cotask::task<>;
auto co_task = simple_task_t::create(
{
});
if (nullptr != co_task)
{
co_task->start();
//auto then_ptr1 = co_task->then(ThenTaskAction1()); // build OK
我这边跟踪了一下原因是后面一种调用在模板参数类型是ThenTaskAction1&, 然而前者解释模板参数类型是ThenTaskAction1
于是我这边的解决方式是
在task_actions.h:91行改成
virtual int operator()(void *priv_data) {
return detail::task_action_functor_check::call(&std::remove_reference<value_type>::type::operator(), functor_, priv_data);
}
去掉了引用
看一下大神有什么好的解决方式或者有什么见解
The text was updated successfully, but these errors were encountered: