https://github.com/typhoonzero/workthreadpool
Lightweight non-locking thread pool for multi-threading work jobs
https://github.com/typhoonzero/workthreadpool
Last synced: about 1 year ago
JSON representation
Lightweight non-locking thread pool for multi-threading work jobs
- Host: GitHub
- URL: https://github.com/typhoonzero/workthreadpool
- Owner: typhoonzero
- License: apache-2.0
- Created: 2015-07-24T01:50:09.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-05-23T09:30:55.000Z (about 10 years ago)
- Last Synced: 2025-03-28T08:41:31.910Z (about 1 year ago)
- Language: C++
- Size: 8.79 KB
- Stars: 13
- Watchers: 8
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workthreadpool
Lightweight non-locking thread pool for multi-threading work jobs..
## Usage
```c++
#include
#include
#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;
}
```