Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion listings/listing_2.6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class scoped_thread
void do_something(int& i)
{
++i;
if (i % 100000 == 0)
printf("%d\n", i);
}

struct func
Expand All @@ -45,7 +47,8 @@ void do_something_in_current_thread()
void f()
{
int some_local_state;
scoped_thread t(std::thread(func(some_local_state)));
// scoped_thread t(std::thread(func(some_local_state)));
scoped_thread t(std::move(std::thread(func(some_local_state))));

do_something_in_current_thread();
}
Expand Down