Compute Graph Framework SDK Reference  5.8
Channel.hpp
Go to the documentation of this file.
1
2//
3// Notice
4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8//
9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
10// information or for any infringement of patents or other rights of third parties that may
11// result from its use. No license is granted by implication or otherwise under any patent
12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
13// expressly authorized by NVIDIA. Details are subject to change without notice.
14// This code supersedes and replaces all information previously supplied.
15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
16// components in life support devices or systems without express written approval of
17// NVIDIA CORPORATION & AFFILIATES.
18//
19// SPDX-FileCopyrightText: Copyright (c) 2018-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
21//
22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
23// property and proprietary rights in and to this material, related
24// documentation and any modifications thereto. Any use, reproduction,
25// disclosure or distribution of this material and related documentation
26// without an express license agreement from NVIDIA CORPORATION or
27// its affiliates is strictly prohibited.
28//
30
31#ifndef DW_FRAMEWORK_CHANNEL_HPP_
32#define DW_FRAMEWORK_CHANNEL_HPP_
33
34#include "ChannelParameters.hpp"
35#include "IChannelPacket.hpp"
36
37#include <dw/core/context/Context.h>
38#include <dwcgf/Exception.hpp>
39#include <dw/core/language/Function.hpp>
40#include <dw/core/container/BaseString.hpp>
41
42#include <memory>
43#include <mutex>
44#include <string>
45
46namespace dw
47{
48namespace framework
49{
50
52static constexpr dwTime_t CHN_WAIT_TIMEOUT_US = 50'000'000;
53
55{
56public:
57 virtual ~ChannelObject() = default;
58
60 {
61 public:
70 virtual void getSyncObjs(dw::core::span<NvSciSyncObj>& syncObjs) = 0;
71 };
72
73 class SyncWaiter : public SyncClient
74 {
75 public:
85 virtual void getWaitFences(void* data, dw::core::span<NvSciSyncFence>& waitFences) = 0;
86 };
87
88 class SyncSignaler : public SyncClient
89 {
90 public:
99 virtual void setSignalFences(void* data, dw::core::span<const NvSciSyncFence> postFences) = 0;
100 };
101
103 {
104 public:
106 {
107 auto* waiter = dynamic_cast<SyncWaiter*>(this);
108 if (waiter == nullptr)
109 {
110 throw Exception(DW_BAD_CAST, "ChannelObject::PacketPool: not a SyncWaiter");
111 }
112 return *waiter;
113 }
114
116 {
117 auto* signaler = dynamic_cast<SyncSignaler*>(this);
118 if (signaler == nullptr)
119 {
120 throw Exception(DW_BAD_CAST, "ChannelObject::PacketPool: not a SyncSignaler");
121 }
122 return *signaler;
123 }
124
134 virtual dwStatus wait(dwTime_t timeout) = 0;
135
136 using OnDataReady = dw::core::Function<void()>;
137
143 virtual void setOnDataReady(void* opaque, OnDataReady onDataReady) = 0;
144 };
145
149 class Producer : public PacketPool
150 {
151 public:
158 virtual dwStatus get(GenericData* data) = 0;
168 virtual dwStatus send(void* data) = 0;
169 };
170
174 class Consumer : public PacketPool
175 {
176 public:
187 virtual dwStatus recv(GenericData* data) = 0;
198 virtual dwStatus release(void* data) = 0;
199 };
200
212
223
228 virtual bool hasClients() const = 0;
229
234 virtual bool isConnected() const = 0;
235
246 virtual dwStatus connect(dwTime_t timeout) = 0;
247
251 virtual const ChannelParams& getParams() const = 0;
252};
253
254} // namespace framework
255} // namespace dw
256
257#endif // DW_FRAMEWORK_CHANNEL_HPP_
virtual dwStatus recv(GenericData *data)=0
virtual dwStatus release(void *data)=0
virtual dwStatus wait(dwTime_t timeout)=0
virtual void setOnDataReady(void *opaque, OnDataReady onDataReady)=0
dw::core::Function< void()> OnDataReady
Definition: Channel.hpp:136
virtual dwStatus get(GenericData *data)=0
virtual dwStatus send(void *data)=0
virtual void getSyncObjs(dw::core::span< NvSciSyncObj > &syncObjs)=0
virtual void setSignalFences(void *data, dw::core::span< const NvSciSyncFence > postFences)=0
virtual void getWaitFences(void *data, dw::core::span< NvSciSyncFence > &waitFences)=0
virtual Producer * getProducer(GenericDataReference ref)=0
virtual const ChannelParams & getParams() const =0
virtual ~ChannelObject()=default
virtual Consumer * getConsumer(GenericDataReference ref)=0
virtual bool isConnected() const =0
virtual dwStatus connect(dwTime_t timeout)=0
virtual bool hasClients() const =0
static constexpr dwTime_t CHN_WAIT_TIMEOUT_US
Definition: Channel.hpp:52
Definition: Exception.hpp:47