Skip to content

Instantly share code, notes, and snippets.

@bzar
Created March 21, 2014 16:19
Show Gist options
  • Save bzar/9689857 to your computer and use it in GitHub Desktop.
Save bzar/9689857 to your computer and use it in GitHub Desktop.
#include <iostream>
#include "../src/promise.h"
int main(int argc, char** argv)
{
Promise<int> p;
p.then<int>([](int const& i) {
std::cout << "1 = " << i << std::endl;
return i + 1;
}).then<int>([](int const& i) {
std::cout << "2 = " << i << std::endl;
return i + 1;
}).then<int>([](int const& i) {
std::cout << "3 = " << i << std::endl;
return i + 1;
});
p.fulfill(1);
p.then<void>([](int const& i) {
std::cout << "1 = " << i << std::endl;
return i;
}).then<void>([]() {
std::cout << "void callback!" << std::endl;
}).then<int>([]() {
std::cout << "void callback 2!" << std::endl;
return 2;
}).then<int>([](int const& i) {
std::cout << "2 = " << i << std::endl;
return i + 1;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment