summaryrefslogtreecommitdiff
path: root/graphics/asymptote/LspCpp/third_party/threadpool/boost/threadpool/shutdown_policies.hpp
blob: 047a6eb516d7d51880f945667c49c2088dd34700 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*! \file
* \brief Shutdown policies.
*
* This file contains shutdown policies for thread_pool. 
* A shutdown policy controls the pool's behavior from the time
* when the pool is not referenced any longer.
*
* Copyright (c) 2005-2007 Philipp Henkel
*
* Use, modification, and distribution are  subject to the
* Boost Software License, Version 1.0. (See accompanying  file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
*
* http://threadpool.sourceforge.net
*
*/


#ifndef THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED
#define THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED



/// The namespace threadpool contains a thread pool and related utility classes.
namespace boost { namespace threadpool
{


/*! \brief ShutdownPolicy which waits for the completion of all tasks 
  *          and the worker termination afterwards.
    *
  * \param Pool The pool's core type.
  */ 
  template<typename Pool>
  class wait_for_all_tasks
  {
  public:
    static void shutdown(Pool& pool)
    {
      pool.wait();
      pool.terminate_all_workers(true);
    }
  };


  /*! \brief ShutdownPolicy which waits for the completion of all active tasks 
  *          and the worker termination afterwards.
  *
  * \param Pool The pool's core type.
  */ 
  template<typename Pool>
  class wait_for_active_tasks
  {
  public:
    static void shutdown(Pool& pool)
    {
      pool.clear();
      pool.wait();
      pool.terminate_all_workers(true);
    }
  };


  /*! \brief ShutdownPolicy which does not wait for any tasks or worker termination.
  *
  * This policy does not wait for any tasks. Nevertheless all active tasks will be processed completely.
  *
  * \param Pool The pool's core type.
  */ 
  template<typename Pool>
  class immediately
  {
  public:
    static void shutdown(Pool& pool)
    {
      pool.clear();
      pool.terminate_all_workers(false);
    }
  };

} } // namespace boost::threadpool

#endif // THREADPOOL_SHUTDOWN_POLICIES_HPP_INCLUDED