Orcus
Loading...
Searching...
No Matches
thread.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef INCLUDED_ORCUS_DETAIL_THREAD_HPP
9#define INCLUDED_ORCUS_DETAIL_THREAD_HPP
10
11#include <thread>
12
13namespace orcus { namespace detail { namespace thread {
14
15class scoped_guard
16{
17 std::thread m_thread;
18public:
19 scoped_guard(std::thread thread) : m_thread(std::move(thread)) {}
20 scoped_guard(scoped_guard&& other) : m_thread(std::move(other.m_thread)) {}
21
22 scoped_guard(const scoped_guard&) = delete;
23 scoped_guard& operator= (const scoped_guard&) = delete;
24
25 ~scoped_guard()
26 {
27 m_thread.join();
28 }
29};
30
31}}}
32
33#endif
34
35/* vim:set shiftwidth=4 softtabstop=4 expandtab: */