Async++ is a framework written in c++ for developing async operations.Features supported
- Async operation
- Advance Logger
- Event Notifers
- Thread Pool
- Stl and Lock Free Queues
- IPC
- Timers
Async::Task([]()// Task 1{/* Funtion with return type Return value will be captured in the next block*/return -100;},[](int x){/*Return type captured here*/// X will be -100}).add([]()//Task 2{/*Function without a return type*/}).execute_async();/* Tasks will be executed asynchronously/parallel*/Async::Task([]()// Task 1{/* Funtion with return type Return value will be captured in the next block*/return -100;},[](int x){/*Return type captured here*/// X will be -100}).add([]()//Task 2{/*Function without a return type*/}).execute_sync();/* Tasks will be executed syncronously*/std::shared_ptr<Async::CancellationToken> Token = make_shared<Async::CancellationToken>();Async::Task([]()// Task 1{/* Funtion with return type Return value will be captured in the next block*/return -100;},[](int x){/*Return type captured here*/// X will be -100}).add([]()//Task 2{/*Function without a return type*/}).setCancellationToken(Token).execute_async();...Token->cancel();/* All the pending tasks will be cancelled, executing tasks cannot be cancelled*/Async::EventListener *pEvent =new Async::EventListener();pEvent->addEvent("event1",[](int x,int y) { cout<<"onEvent1_1"<<endl; });pEvent->addEvent("event1",[](int x,int y) { cout<<"onEvent1_2"<<endl; });pEvent->addEvent("event2",[](int x,int y){ cout<<"onEvent2"<<endl; });pEvent->addEvent("event3",[](){ cout<<"onEvent3"<<endl; });pEvent->notify_sync("event1",10,100);pEvent->notify_async("event2");pEvent->notify_async("event3");classTimerExample :publicAsync::ITimer{ shared_ptr<Async::TimerTicks>mTicks;public:TimerExample():mTicks(make_shared<Async::TimerTicks>(this)) {this->mTicks->setInterval(1);//Timer set for 1 secthis->mTicks->start();//Starting timer }~TimerExample() { }voidonTimerExpired(Async::TimerTicks *pTicks) {//Callback after the timer expiry... }};IPC::MessageQueuemyQ(/* Q name*/,/* Q size*/,/* message size*/,/* is to create or not*/);myQ.recv([](shared_ptr<char> ptr,size_t size)//Asynchronous receive{});myQ.read(/* buffer ptr*/,/* size*/);//Synchronous receivemyQ.send(/* buffer ptr*/,/* size*/);//Synchronous sendCore::Channel<int> c;// Creating a channelc <<10;// Send to channelint x;x << c;//Receving from channelc.close();//Closing the channel
Core::WaitGroup wg;// Creating a wait groupwg.add()// adding to waitgroup adding 1 to counterwg.add(10)// adding to waitgroup adding 10 to counterwg.done()// wait group is done and decrease counter by 1wg.wait()// wait for wait group to complete , ie counter becomes 0