diff --git a/test/src/cpp11/.vscode/launch.json b/test/src/cpp11/.vscode/launch.json index 50477bc..ce05d7a 100644 --- a/test/src/cpp11/.vscode/launch.json +++ b/test/src/cpp11/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "C++ Launch (GDB)", "type": "cppdbg", "request": "launch", - "program": "${workspaceFolder}/cpp11.exe", + "program": "cpp11.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", diff --git a/test/src/cpp11/.vscode/settings.json b/test/src/cpp11/.vscode/settings.json index e2c18d1..9dc95fe 100644 --- a/test/src/cpp11/.vscode/settings.json +++ b/test/src/cpp11/.vscode/settings.json @@ -1,5 +1,55 @@ { "files.associations": { - "ostream": "cpp" + "ostream": "cpp", + "cstdint": "cpp", + "future": "cpp", + "thread": "cpp", + "iostream": "cpp", + "algorithm": "cpp", + "atomic": "cpp", + "chrono": "cpp", + "cmath": "cpp", + "condition_variable": "cpp", + "cstddef": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "cwchar": "cpp", + "exception": "cpp", + "resumable": "cpp", + "functional": "cpp", + "initializer_list": "cpp", + "ios": "cpp", + "iosfwd": "cpp", + "istream": "cpp", + "limits": "cpp", + "list": "cpp", + "memory": "cpp", + "mutex": "cpp", + "new": "cpp", + "ratio": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "system_error": "cpp", + "xthread": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "typeinfo": "cpp", + "unordered_map": "cpp", + "utility": "cpp", + "vector": "cpp", + "xfacet": "cpp", + "xhash": "cpp", + "xiosbase": "cpp", + "xlocale": "cpp", + "xlocinfo": "cpp", + "xlocnum": "cpp", + "xmemory": "cpp", + "xmemory0": "cpp", + "xstddef": "cpp", + "xstring": "cpp", + "xtr1common": "cpp", + "xutility": "cpp", + "ctime": "cpp" } } \ No newline at end of file diff --git a/test/src/cpp11/CMakeLists.txt b/test/src/cpp11/CMakeLists.txt index 991424e..b6d1606 100644 --- a/test/src/cpp11/CMakeLists.txt +++ b/test/src/cpp11/CMakeLists.txt @@ -3,5 +3,6 @@ project(cpp11) message("current dir" ${CMAKE_CURRENT_SOURCE_DIR}) - -add_executable(cpp11 cpp11_test.cpp ) \ No newline at end of file +aux_source_directory(. SOURCE) +message(info ${SOURCE}) +add_executable(cpp11 ${SOURCE} ) \ No newline at end of file diff --git a/test/src/cpp11/cpp11_test.cpp b/test/src/cpp11/cpp11_test.cpp index ad47ce4..4f75b55 100644 --- a/test/src/cpp11/cpp11_test.cpp +++ b/test/src/cpp11/cpp11_test.cpp @@ -1,10 +1,14 @@ #include using namespace std; #include +#include "thread_usage.h" int main(){ - int x; - cout<<"hello world"<& promiseObj) { + std::cout << "In a thread, making data. wait for 10 seconds"< promiseObj; + std::future futureObj = promiseObj.get_future(); + std::thread t(&thread_set_promise, std::ref(promiseObj)); + + while (std::future_status::timeout == futureObj.wait_for(std::chrono::milliseconds(1000))){ + static uint32_t times = 0; + times ++; + std::cout<<"time out "<< times < +#include +#include +#include +#include +#include +#include +#include + +void TestPromiseFutureBefore(); +void TestThreadDetch(); \ No newline at end of file