This file contains hidden or 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
cmake_minimum_required(VERSION 2.8) | |
project(test) | |
add_executable(future_test future_test.cc) | |
set(Boost_USE_STATIC_LIBS ON) | |
set(Boost_DEBUG ON) | |
find_package(Boost COMPONENTS date_time thread system chrono) | |
target_compile_options(future_test PUBLIC -std=c++11 -pthread) | |
target_include_directories(future_test PUBLIC ${Boost_INCLUDE_DIRS}) | |
target_link_libraries(future_test ${Boost_LIBRARIES} pthread) |
This file contains hidden or 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 <chrono> | |
#include <future> | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
#include "boost/thread/future.hpp" | |
int main() { | |
{ |
This file contains hidden or 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
Place holder for project API |
This file contains hidden or 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<chrono> | |
#include<thread> | |
#include <boost/thread/future.hpp> | |
int Task(int x, std::chrono::time_point<std::chrono::high_resolution_clock> start) { | |
std::chrono::time_point<std::chrono::high_resolution_clock> end; | |
std::cout << std::endl << "Starting : " << x << std::endl; | |
std::this_thread::sleep_for(std::chrono::milliseconds(10 * x)); |