summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv/multi_threading_utils.h
blob: c139f938a55214ab4643a0ef2069b746fb86bb31 (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
// Copyright (C) 2019-2020 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef MULTI_THREADING_UTIL_H
#define MULTI_THREADING_UTIL_H

#include <boost/noncopyable.hpp>

namespace isc {
namespace dhcp {

/// @note: everything here MUST be used ONLY from the main thread.
/// When called from a thread of the pool it can deadlock.

/// @brief Function stopping and joining all threads of the pool.
/// @throw isc::NotImplemented until is implemented.
void stopPktProcessing();

/// @brief Function (re)starting threads of the pool.
/// @throw isc::NotImplemented until is implemented.
void startPktProcessing();

/// @brief RAII class creating a critical section.
///
/// @note: the multi-threading mode MUST NOT be changed in the RAII
/// @c MultiThreadingCriticalSection body.
class MultiThreadingCriticalSection : public boost::noncopyable {
public:
    /// @brief Constructor.
    /// Entering the critical section.
    MultiThreadingCriticalSection();

    /// @brief Destructor.
    /// Leaving the critical section.
    virtual ~MultiThreadingCriticalSection();

    /// @brief Class method stopping and joining all threads of the pool.
    /// @throw isc::NotImplemented until is implemented.
    static void stopPktProcessing();

    /// @brief Class method (re)starting threads of the pool.
    /// @throw isc::NotImplemented until is implemented.
    static void startPktProcessing();
};

}  // namespace dhcp
}  // namespace isc

#endif // MULTI_THREADING_UTIL_H