Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An Asynchronous C++ framework

NotificationsYou must be signed in to change notification settings

vishnuvijayanklm/Asyncpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

123 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Examples

Task

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*/

Cancellable Task

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*/

EventListeners

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");

Timer

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 Message Queue

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 send

Channels

Core::Channel<int> c;// Creating a channelc <<10;// Send to channelint x;x << c;//Receving from channelc.close();//Closing the channel

WaitGroup

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

About

An Asynchronous C++ framework

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2026 Movatter.jp