Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ implementing cancel across thread pools

I have several thread pools and I want my application to handle a cancel operation.

To do this I implemented a shared operation controller object which I poll at various spots in each thread pool worker function that is called.

Is this a good model, or is there a better way to do it?

I just worry about having all of these operationController.checkState() littered throughout the code.

like image 893
Net Citizen Avatar asked Mar 01 '23 17:03

Net Citizen


1 Answers

Yes it's a good approach. Herb Sutter has a nice article comparing it with the alternatives (which are worse).

like image 174
timday Avatar answered Mar 11 '23 23:03

timday