Skip to content

typhoonzero/workthreadpool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

workthreadpool

Lightweight non-locking thread pool for multi-threading work jobs..

Usage

#include <sstream>
#include <math.h>
#include "workthreadpool.h"

class MyThreadPool : public bfd::WorkThreadPool {
 public:
  MyThreadPool(int size) : bfd::WorkThreadPool(size) {
  }
  void Handle(const string &msg) {
    stringstream ss;
    ss << "worker (" << std::this_thread::get_id() << ") got msg: " << msg;
    printf("%s\n", ss.str().c_str());
    for (int i=0; i<=999999; i++) {
      double result = sqrt(sqrt(i) / 93.234);
    }
  }
};

int main() {
  printf("start running ....\n");
  MyThreadPool pool(5);
  pool.Start();
  for (int i=0; i<100; i++) {
    pool.SendMessage("msg info ----------");
  }
  pool.Stop();

  return 0;
}

About

Lightweight non-locking thread pool for multi-threading work jobs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published