Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
Toggle main menu visibility
Loading...
Searching...
No Matches
network_task.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2015 Roc Streaming authors
3
*
4
* This Source Code Form is subject to the terms of the Mozilla Public
5
* License, v. 2.0. If a copy of the MPL was not distributed with this
6
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
*/
8
9
//! @file roc_netio/target_libuv/roc_netio/network_task.h
10
//! @brief Network task.
11
12
#ifndef ROC_NETIO_NETWORK_TASK_H_
13
#define ROC_NETIO_NETWORK_TASK_H_
14
15
#include "
roc_core/atomic.h
"
16
#include "
roc_core/mpsc_queue_node.h
"
17
#include "
roc_core/optional.h
"
18
#include "roc_core/semaphore.h"
19
#include "
roc_core/shared_ptr.h
"
20
#include "
roc_netio/basic_port.h
"
21
22
namespace
roc
{
23
namespace
netio
{
24
25
class
NetworkLoop
;
26
class
INetworkTaskCompleter
;
27
28
//! Base class for network loop tasks.
29
class
NetworkTask :
public
core::MpscQueueNode
<> {
30
public
:
31
~NetworkTask();
32
33
//! Check that the task finished and succeeded.
34
bool
success
()
const
;
35
36
protected
:
37
friend
class
NetworkLoop;
38
39
NetworkTask();
40
41
//! Task state.
42
enum
State
{
43
StateInitialized,
44
StatePending,
45
StateClosingPort,
46
StateFinishing,
47
StateFinished
48
};
49
50
//! Task implementation method.
51
void (NetworkLoop::*
func_
)(NetworkTask&);
52
53
//! Task state, defines whether task is finished already.
54
//! The task becomes immutable after setting state to Finished.
55
core::Atomic<int>
state_
;
56
57
//! Task result, defines wether finished task succeeded or failed.
58
//! Makes sense only after setting state_ to Finished.
59
//! This atomic should be assigned before setting state_ to Finished.
60
core::Atomic<int>
success_
;
61
62
core::SharedPtr<BasicPort>
port_
;
//!< On which port the task operates.
63
void
*
port_handle_
;
//!< Port handle.
64
65
INetworkTaskCompleter
*
completer_
;
//!< Completion handler.
66
core::Optional<core::Semaphore>
sem_
;
//!< Completion semaphore.
67
};
68
69
}
// namespace netio
70
}
// namespace roc
71
72
#endif
// ROC_NETIO_NETWORK_TASK_H_
atomic.h
Atomic.
basic_port.h
Base class for ports.
roc::core::Atomic
Atomic integer. Provides sequential consistency. For a fine-grained memory order control,...
Definition
atomic.h:26
roc::core::MpscQueueNode
Base class for MpscQueue element.
Definition
mpsc_queue_node.h:43
roc::core::Optional
Optionally constructed object.
Definition
optional.h:25
roc::core::SharedPtr
Shared ownership intrusive pointer.
Definition
shared_ptr.h:32
roc::netio::INetworkTaskCompleter
Network task completion handler.
Definition
inetwork_task_completer.h:21
roc::netio::NetworkLoop
Network event loop thread.
Definition
network_loop.h:52
roc::netio::NetworkTask::port_
core::SharedPtr< BasicPort > port_
On which port the task operates.
Definition
network_task.h:62
roc::netio::NetworkTask::func_
void(NetworkLoop::* func_)(NetworkTask &)
Task implementation method.
Definition
network_task.h:51
roc::netio::NetworkTask::port_handle_
void * port_handle_
Port handle.
Definition
network_task.h:63
roc::netio::NetworkTask::completer_
INetworkTaskCompleter * completer_
Completion handler.
Definition
network_task.h:65
roc::netio::NetworkTask::state_
core::Atomic< int > state_
Task state, defines whether task is finished already. The task becomes immutable after setting state ...
Definition
network_task.h:55
roc::netio::NetworkTask::success
bool success() const
Check that the task finished and succeeded.
roc::netio::NetworkTask::sem_
core::Optional< core::Semaphore > sem_
Completion semaphore.
Definition
network_task.h:66
roc::netio::NetworkTask::success_
core::Atomic< int > success_
Task result, defines wether finished task succeeded or failed. Makes sense only after setting state_ ...
Definition
network_task.h:60
roc::netio::NetworkTask::State
State
Task state.
Definition
network_task.h:42
mpsc_queue_node.h
MpscQueue node.
roc::netio
Network I/O.
roc
Root namespace.
optional.h
Optionally constructed object.
shared_ptr.h
Shared ownership intrusive pointer.
roc_netio
target_libuv
roc_netio
network_task.h
Generated by
1.17.0