Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site











SourceForge.net Logo

AsyncWork and Async

 

template <class Ret>

class AsyncWork

Represents a job that can be executed in another thread and can return a value. It is similar to future/promise pattern, but it allows cancelation and is based on U++ thread pool shared with CoWork. AsyncWork has pick constructor / operator.

 

Public Method List

 

template < class Function, class... Args>

void Do(Function&& f, Args&&... args)

Schedules job f with parameters args to be asynchronously performed in (possibly) another thread.

 


 

void Cancel()

Cancels the job.

 


 

static bool IsCanceled()

Returns true in the job routine if the master AsyncWork was canceled.

 


 

bool IsFinished()

Returns true if job was finished.

 


 

Ret Get()

Waits for job to be finished (if necessary), then returns the return value of f. If there was exception, it is rethrown.

 


 

Ret operator~()

Same as Get().

 

 


 

Ret Pick()

Similar to Get, but uses pick constructor instead of copy constructor to pass the return value.

 


 

~AsyncWork()

If work has not be finished, destructor cancels it.

 

Async

 

auto Async(Function&& f, Args&&... args)

Returns AsyncWork for given job f with args.

 

 

Last edit by cxl on 02/18/2020. Do you want to contribute?. T++