Run clang-format
This commit is contained in:
@@ -1,58 +1,57 @@
|
||||
#include <thread>
|
||||
|
||||
class thread_guard
|
||||
{
|
||||
std::thread& t;
|
||||
class thread_guard {
|
||||
std::thread& t;
|
||||
|
||||
public:
|
||||
explicit thread_guard(std::thread& t_):
|
||||
t(t_)
|
||||
{}
|
||||
~thread_guard()
|
||||
{
|
||||
if(t.joinable())
|
||||
{
|
||||
t.join();
|
||||
}
|
||||
explicit thread_guard(std::thread& t_) : t(t_) {}
|
||||
~thread_guard()
|
||||
{
|
||||
if (t.joinable()) {
|
||||
t.join();
|
||||
}
|
||||
thread_guard(thread_guard const&)=delete;
|
||||
thread_guard& operator=(thread_guard const&)=delete;
|
||||
}
|
||||
thread_guard(thread_guard const&) = delete;
|
||||
thread_guard& operator=(thread_guard const&) = delete;
|
||||
};
|
||||
|
||||
void do_something(int& i)
|
||||
void
|
||||
do_something(int& i)
|
||||
{
|
||||
++i;
|
||||
++i;
|
||||
}
|
||||
|
||||
struct func
|
||||
{
|
||||
int& i;
|
||||
struct func {
|
||||
int& i;
|
||||
|
||||
func(int& i_):i(i_){}
|
||||
func(int& i_) : i(i_) {}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
for(unsigned j=0;j<1000000;++j)
|
||||
{
|
||||
do_something(i);
|
||||
}
|
||||
void operator()()
|
||||
{
|
||||
for (unsigned j = 0; j < 1000000; ++j) {
|
||||
do_something(i);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void do_something_in_current_thread()
|
||||
{}
|
||||
|
||||
|
||||
void f()
|
||||
void
|
||||
do_something_in_current_thread()
|
||||
{
|
||||
int some_local_state;
|
||||
func my_func(some_local_state);
|
||||
std::thread t(my_func);
|
||||
thread_guard g(t);
|
||||
|
||||
do_something_in_current_thread();
|
||||
}
|
||||
|
||||
int main()
|
||||
void
|
||||
f()
|
||||
{
|
||||
f();
|
||||
int some_local_state;
|
||||
func my_func(some_local_state);
|
||||
std::thread t(my_func);
|
||||
thread_guard g(t);
|
||||
|
||||
do_something_in_current_thread();
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
f();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user