As far as I can tell from the code, you will have threads with start_task_proc somewhere in your stack that calls their function object. You can change this function by pointing to the "task information" structure, and not to the bare function object. You can use any information that you like in this information object, for example. line numbers and file names in which you created the task:
template <class T> struct TaksInfo { T func; unsigned line; char const* file; TaskInfo(T&& t, unsigned l, char const* f) : func(std::move(t), line(l), file(f) {} }; template<typename T> smart_ptrs::w32handle StartTask(T f, unsigned line, char const* file) {
If you are now checking pTask in start_task_proc , you can see file and line that can tell you where the task was run.
Of course, you could avoid the TaskInfo structure and make the information just a parameter to the start_task_proc template:
template <class T, unsigned Line, char const* File> DWORD start_task_proc(LPVOID lpParameter) { ) template<unsigned Line, char const* File, typename T>
Arne mertz
source share