Run clang-format
This commit is contained in:
@@ -1,56 +1,55 @@
|
||||
#include <thread>
|
||||
#include <utility>
|
||||
|
||||
class scoped_thread
|
||||
{
|
||||
std::thread t;
|
||||
class scoped_thread {
|
||||
std::thread t;
|
||||
|
||||
public:
|
||||
explicit scoped_thread(std::thread t_):
|
||||
t(std::move(t_))
|
||||
{
|
||||
if(!t.joinable())
|
||||
throw std::logic_error("No thread");
|
||||
}
|
||||
~scoped_thread()
|
||||
{
|
||||
t.join();
|
||||
}
|
||||
scoped_thread(scoped_thread const&)=delete;
|
||||
scoped_thread& operator=(scoped_thread const&)=delete;
|
||||
explicit scoped_thread(std::thread t_) : t(std::move(t_))
|
||||
{
|
||||
if (!t.joinable())
|
||||
throw std::logic_error("No thread");
|
||||
}
|
||||
~scoped_thread() { t.join(); }
|
||||
scoped_thread(scoped_thread const&) = delete;
|
||||
scoped_thread& operator=(scoped_thread 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;
|
||||
scoped_thread t(std::thread(func(some_local_state)));
|
||||
|
||||
do_something_in_current_thread();
|
||||
}
|
||||
|
||||
int main()
|
||||
void
|
||||
f()
|
||||
{
|
||||
f();
|
||||
int some_local_state;
|
||||
scoped_thread t(std::thread(func(some_local_state)));
|
||||
|
||||
do_something_in_current_thread();
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
f();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user