forked from bloomberg/ntf-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ntci_driver.h
102 lines (88 loc) · 3.8 KB
/
ntci_driver.h
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Copyright 2020-2023 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef INCLUDED_NTCI_DRIVER
#define INCLUDED_NTCI_DRIVER
#include <bsls_ident.h>
BSLS_IDENT("$Id: $")
#include <ntca_waiteroptions.h>
#include <ntccfg_platform.h>
#include <ntci_datagramsocketfactory.h>
#include <ntci_datapool.h>
#include <ntci_executor.h>
#include <ntci_listenersocketfactory.h>
#include <ntci_strand.h>
#include <ntci_strandfactory.h>
#include <ntci_streamsocketfactory.h>
#include <ntci_timerfactory.h>
#include <ntci_waiter.h>
#include <ntcscm_version.h>
namespace BloombergLP {
namespace ntci {
/// Provide an interface to drive the I/O and events for sockets and timers.
///
/// @par Thread Safety
/// This class is thread safe.
///
/// @ingroup module_ntci_runtime
class Driver : public ntci::Executor,
public ntci::TimerFactory,
public ntci::StrandFactory,
public ntci::DatagramSocketFactory,
public ntci::ListenerSocketFactory,
public ntci::StreamSocketFactory,
public ntci::DataPool
{
public:
/// Destroy this object.
virtual ~Driver();
/// Register a thread described by the specified 'waiterOptions' that
/// will drive this object. Return the handle to the waiter.
virtual ntci::Waiter registerWaiter(
const ntca::WaiterOptions& waiterOptions) = 0;
/// Deregister the specified 'waiter'.
virtual void deregisterWaiter(ntci::Waiter waiter) = 0;
/// Block the calling thread until stopped. As each socket enters the
/// state in which interest has been registered, or each timer fires,
/// invoke the corresponding processing function on the associated
/// descriptor or timer. The behavior is undefined unless the calling
/// thread has previously registered the 'waiter'. Note that after this
/// function returns, the 'restart' function must be called before this
/// or the 'run' function can be called again.
virtual void run(ntci::Waiter waiter) = 0;
/// Block the calling thread identified by the specified 'waiter', until
/// at least one socket enters the state in which interest has been
/// registered, or timer fires. For each socket that has entered the
/// state in which interest has been registered, or each timer that has
/// fired, invoke the corresponding processing function on the
/// associated descriptor or timer. The behavior is undefined unless the
/// calling thread has previously registered the 'waiter'. Note that
/// if this function returns because 'stop' was called, the 'restart'
/// function must be called before this or the 'run' function can be
/// called again.
virtual void poll(ntci::Waiter waiter) = 0;
/// Unblock and return one caller blocked on either 'poll' or 'run'.
virtual void interruptOne() = 0;
/// Unblock and return any caller blocked on either 'poll' or 'run'.
virtual void interruptAll() = 0;
/// Unblock and return any caller blocked on either 'poll' or 'run',
/// and stop running, if necessary.
virtual void stop() = 0;
/// Prepare the reactor for 'run' to be called again after previously
/// being stopped.
virtual void restart() = 0;
};
} // end namespace ntci
} // end namespace BloombergLP
#endif