Created
March 21, 2014 16:19
-
-
Save bzar/9689857 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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