Skip to content

How to pass function of classe #22

Description

@LeMoussel

I have this class

 class MyTask
 {
 public:
 	// Function to be executed by thread function
 	void run()
 	{
 		std::cout << "Task Start" << std::endl;
 
 		// Check if thread is requested to stop ?
 		while (stopRequested() == false)
 		{
 			std::cout << "Doing Some Work" << std::endl;
 			std::this_thread::sleep_for(std::chrono::milliseconds(1000));
 
 		}
 		std::cout << "Task End" << std::endl;
 	}
 };

I do
MyTask task; ctpl::thread_pool testThreadPool(4);

How can I push task.run() to ctpl::thread_pool?
testThreadPool.push(task.run);, isn't correct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions