Thrill  0.1
request_queue_impl_worker.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  * foxxll/io/request_queue_impl_worker.hpp
3  *
4  * Part of FOXXLL. See http://foxxll.org
5  *
6  * Copyright (C) 2002 Roman Dementiev <[email protected]>
7  * Copyright (C) 2008, 2009 Andreas Beckmann <[email protected]>
8  * Copyright (C) 2009 Johannes Singler <[email protected]>
9  * Copyright (C) 2013 Timo Bingmann <[email protected]>
10  *
11  * Distributed under the Boost Software License, Version 1.0.
12  * (See accompanying file LICENSE_1_0.txt or copy at
13  * http://www.boost.org/LICENSE_1_0.txt)
14  **************************************************************************/
15 
16 #ifndef FOXXLL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
17 #define FOXXLL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
18 
19 #include <thread>
20 
22 #include <foxxll/config.hpp>
24 #include <tlx/semaphore.hpp>
25 
26 namespace foxxll {
27 
28 //! \addtogroup foxxll_reqlayer
29 //! \{
30 
31 //! Implementation of request queue worker threads. Worker threads can be
32 //! started by start_thread and stopped with stop_thread. The queue state is
33 //! checked before termination and updated afterwards.
35 {
36 protected:
38 
39 protected:
40  void start_thread(
41  void* (*worker)(void*), void* arg,
42  std::thread& t, shared_state<thread_state>& s);
43 
44  void stop_thread(
45  std::thread& t, shared_state<thread_state>& s, tlx::semaphore& sem);
46 };
47 
48 //! \}
49 
50 } // namespace foxxll
51 
52 #endif // !FOXXLL_IO_REQUEST_QUEUE_IMPL_WORKER_HEADER
53 
54 /**************************************************************************/
A simple semaphore implementation using C++11 synchronization methods.
Definition: semaphore.hpp:26
Interface of a request_queue to which requests can be added and canceled.
FOXXLL library namespace
void stop_thread(std::thread &t, shared_state< thread_state > &s, tlx::semaphore &sem)
void start_thread(void *(*worker)(void *), void *arg, std::thread &t, shared_state< thread_state > &s)