Skip to content

NOMORECOFFEE/async

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async

The framework for supporting a style of parallel programming in which problems are solved by (recursively) splitting them into subtasks that are solved in parallel, waiting for them to complete, and then composing results.

The fork/join framework provides a very straightforward and intuitive structure to conquer problems.

example

int sequentialFibonacci(n);

void combineFibonacci(int x, int y, function<void(int)> sendResult)
{
  sendResult(x + y);
}

void calculateFibonacci(asio::io_service& theService, int n, function<void(int)> onComplete)
{
  if (n <= threshold)
  {
    onComplete(sequentialFibonacci(n));
  }
  else
  {
    async<void(int), void(int)>(
        io_service,
        bind(calculateFibonacci, ref(theService), n - 1, _1),
        bind(calculateFibonacci, ref(theService), n - 2, _1),
        bind(combineFibonacci, _1, _2, onComplete));
  }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published