Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
pipeline_task.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 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_pipeline/pipeline_task.h
10
//! @brief Base class for pipeline tasks.
11
12
#ifndef ROC_PIPELINE_PIPELINE_TASK_H_
13
#define ROC_PIPELINE_PIPELINE_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
20
namespace
roc
{
21
namespace
pipeline {
22
23
class
PipelineLoop;
24
class
IPipelineTaskCompleter;
25
26
//! Base class for pipeline tasks.
27
class
PipelineTask
:
public
core::MpscQueueNode
{
28
public
:
29
~
PipelineTask
();
30
31
//! Check that the task finished and succeeded.
32
bool
success
()
const
;
33
34
protected
:
35
PipelineTask
();
36
37
private
:
38
friend
class
PipelineLoop
;
39
40
enum
{ StateNew, StateScheduled, StateFinished };
41
42
// Task state, defines whether task is finished already.
43
// The task becomes immutable after setting state_ to StateFinished;
44
core::Atomic<int>
state_;
45
46
// Task result, defines wether finished task succeeded or failed.
47
// Makes sense only after setting state_ to StateFinished.
48
// This atomic should be assigned before setting state_ to StateFinished.
49
core::Atomic<int>
success_;
50
51
// Completion handler;
52
IPipelineTaskCompleter
* completer_;
53
54
// Completion semaphore.
55
core::Optional<core::Semaphore>
sem_;
56
};
57
58
}
// namespace pipeline
59
}
// namespace roc
60
61
#endif
// ROC_PIPELINE_PIPELINE_TASK_H_
atomic.h
Atomic.
roc::core::Atomic< int >
roc::core::MpscQueueNode
MpscQueue node.
Definition:
mpsc_queue_node.h:24
roc::core::Optional
Optionally constructed object.
Definition:
optional.h:25
roc::pipeline::IPipelineTaskCompleter
Pipeline task completion handler.
Definition:
ipipeline_task_completer.h:21
roc::pipeline::PipelineLoop
Base class for task-based pipelines.
Definition:
pipeline_loop.h:193
roc::pipeline::PipelineTask
Base class for pipeline tasks.
Definition:
pipeline_task.h:27
roc::pipeline::PipelineTask::success
bool success() const
Check that the task finished and succeeded.
mpsc_queue_node.h
MpscQueue node.
roc
Root namespace.
optional.h
Optionally constructed object.
roc_pipeline
pipeline_task.h
Generated by
1.9.1