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().

 

 


 

~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/22/2018. Do you want to contribute?. T++