lzpong / threadpool

based on C++11 , a mini threadpool , accept variable number of parameters 基于C++11的线程池,简洁且可以带任意多的参数

Home Page:http://www.cnblogs.com/lzpong/p/6397997.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

为何仅支持静态的成员函数,普通的成员函数为何不支持呢?

windflowerly opened this issue · comments

为何仅支持静态的成员函数,普通的成员函数为何不支持呢?

commented

+1
同问,怎么支持普通成员函数。
实际使用时,基本需求的都是普通函数。

commented

为何仅支持静态的成员函数,普通的成员函数为何不支持呢?

找到解决方法了:使用std::mem_fn处理

具体:mem_fn:executor.commit(std::mem_fn(&MMyClass::MMethod),this);
MMethod方法就是普通函数。

commented

@lzpong Please Close this Issue!

没看 readme , 有说明的

commit 直接使用只能调用stdcall函数,但有两种方法可以实现调用类成员,一种是使用 bind: .commit(std::bind(&Dog::sayHello, &dog)); 一种是用 mem_fn: .commit(std::mem_fn(&Dog::sayHello), &dog);```