David Blume's GitList
Repositories
testcode.git
Code
Commits
Branches
Tags
Search
Tree:
9d5b420
Branches
Tags
c++11
main
start
testcode.git
product
thread_with_lambda.cpp
Added a routine to cause a deadlock. See http://wiki.dlma.com/gdb for more.
David Blume
commited
9d5b420
at 2016-10-16 20:24:34
thread_with_lambda.cpp
Blame
History
Raw
#include <thread> #include <mutex> #include <iostream> #include "thread_with_lambda.hpp" namespace { std::mutex my_mutex; std::thread worker; } void thread_with_lambda() { uint32_t ticks = 10; std::lock_guard<std::mutex> lock(my_mutex); worker = std::thread([=]{ for(uint32_t tick = 0; tick <= ticks; tick++) { std::cout << __PRETTY_FUNCTION__ << " count " << tick << std::endl; } }); if (worker.joinable()) worker.join(); }