A simple event-driven programming library.
Originally I wrote this code for the Jim's event-loop (Jim is a Tcl interpreter) but later translated it in form of a library for easy reuse.
示例
main.c
#include "ae.h"
#include <iostream>
using namespace std;
void Proc(struct aeEventLoop *eventLoop, int fd, void *clientData, int mask)
{
cout<<"proc"<<endl;
aeStop(eventLoop);
}
int main()
{
cout<<"hello world"<<endl;
aeEventLoop *loop = aeCreateEventLoop(64);
if(loop != nullptr) {
//cout<<loop->setsize<<endl;
cout<<aeGetSetSize(loop)<<endl;
cout<<aeGetApiName()<<endl;
/*long seconds, milliseconds;
aeGetTime(&seconds, &milliseconds);
cout<<seconds<<endl<<milliseconds<<endl;*/
aeCreateFileEvent(loop, 0, 1, Proc, nullptr);
aeMain(loop);
//aeStop(loop);
aeDeleteEventLoop(loop);
}
return 0;
}