std::thread
takes its arguments by value. You can get reference semantics back by using std::reference_wrapper
:
std::thread newThread(session, &sock, std::ref(logger));
Obviously you must make sure that logger
outlives the thread.
More Related Contents:
- What happens to a detached thread when main() exits?
- Passing object by reference to std::thread in C++11
- Thread pooling in C++11
- How to check if a std::thread is still running?
- Difference between pointer and reference as thread parameter
- I want to kill a std::thread using its thread object? [duplicate]
- Start thread with member function
- C++0x has no semaphores? How to synchronize threads?
- When should I use std::thread::detach?
- Why is the destructor of a future returned from `std::async` blocking?
- What does the thread_local mean in C++11?
- Does MinGW-w64 support std::thread out of the box when using the Win32 threading model?
- What exactly is std::atomic?
- How would you implement your own reader/writer lock in C++11?
- Mixing C++11 atomics and OpenMP
- Why user-defined move-constructor disables the implicit copy-constructor?
- std::unique_lock or std::lock_guard?
- Does the C++ volatile keyword introduce a memory fence?
- How to set the stacksize with C++11 std::thread
- How can I use something like std::vector?
- What is std::promise?
- Passing arguments to std::async by reference fails
- Portable way of setting std::thread priority in C++11
- Waiting for multiple futures?
- Double-Checked Lock Singleton in C++11
- std::thread::join() hangs if called after main() exits when using VS2012 RC
- thread safety of MPI send using threads created with std::async
- C++11 ‘native_handle’ is not a member of ‘std::this_thread’
- C++11 Implementation of Spinlock using header “
- About thread-safety of weak_ptr