Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bionelabs/eventloop
A simple C thread pool implementation with single core
https://github.com/bionelabs/eventloop
c caophuocthanh eventloop onebuffer queue xcode
Last synced: 16 days ago
JSON representation
A simple C thread pool implementation with single core
- Host: GitHub
- URL: https://github.com/bionelabs/eventloop
- Owner: bionelabs
- License: mit
- Created: 2020-04-24T17:39:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-04-24T17:47:21.000Z (over 4 years ago)
- Last Synced: 2024-11-05T11:43:00.794Z (2 months ago)
- Topics: c, caophuocthanh, eventloop, onebuffer, queue, xcode
- Language: C
- Homepage: https://onebuffer.com
- Size: 44.9 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EventLoop
A simple C thread pool implementation with single core## Include:
- setTimeOut
- setImmedate
- setInterval
- emit and listen## Use
```c++
include
#include
#include
#include "EventLoop.h"static int addTaskO = 0;
void calbackTaskA() {
printf("A event calback\n");
}void calbackTaskB() {
printf("B event calback\n");
if (addTaskO == 0) { // add more task when all stask runing
addTaskO = 1;
}
EventShared().setImmedate(calbackTaskA);
EventShared().emit(4555, "hjgjhgjhg", "df", 2342);
}void calbackTaskC() {
printf("C event calback\n");
EventShared().emit(4555, "6666666666ghfjghf", "9999999999999jhgfjhgfj", "2342");
}void calbackTaskD() {
printf("D event calback\n");
}void calbackStopProcess() {
printf("calbackStopProcess\n");
EventShared().remove(4555);
EventShared().exit();
}int main(int argc, const char * argv[]) {
// add Tasks
EventShared().setImmedate(calbackTaskA);
EventShared().setInterval(calbackTaskB, 5*1000);
EventShared().setTimeout(calbackTaskB, 10*1000);
EventShared().setTimeout(calbackStopProcess, 120*1000);
EventShared().setTimeout(calbackTaskA, 2*1000);
EventShared().setTimeout(calbackTaskB, 2*1000);
EventShared().setInterval(calbackTaskC, 2*1000);
// run loop
EventShared().loop();return 0;
}```
## Contact
- Email: [email protected]
- Site: https://onebuffer.com
- Linkedin: https://www.linkedin.com/in/caophuocthanh/