Compute Graph Framework SDK Reference
5.4.5418 Release
For Test and Development only

Channel.hpp
Go to the documentation of this file.
1 //
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-2021 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 
46 namespace dw
47 {
48 namespace framework
49 {
50 
52 static constexpr dwTime_t CHN_WAIT_TIMEOUT_US = 50'000'000;
53 
55 {
56 public:
57  virtual ~ChannelObject() = default;
58 
59  class SyncClient
60  {
61  public:
71  virtual void getSyncObjs(dw::core::span<NvSciSyncObj>& syncObjs) = 0;
72  };
73 
74  class SyncWaiter : public SyncClient
75  {
76  public:
87  virtual void getWaitFences(void* data, dw::core::span<NvSciSyncFence>& waitFences) = 0;
88  };
89 
90  class SyncSignaler : public SyncClient
91  {
92  public:
101  virtual void setSignalFences(void* data, dw::core::span<const NvSciSyncFence> postFences) = 0;
102  };
103 
105  {
106  public:
108  {
109  auto* waiter = dynamic_cast<SyncWaiter*>(this);
110  if (waiter == nullptr)
111  {
112  throw Exception(DW_BAD_CAST, "ChannelObject::PacketPool: not a SyncWaiter");
113  }
114  return *waiter;
115  }
116 
118  {
119  auto* signaler = dynamic_cast<SyncSignaler*>(this);
120  if (signaler == nullptr)
121  {
122  throw Exception(DW_BAD_CAST, "ChannelObject::PacketPool: not a SyncSignaler");
123  }
124  return *signaler;
125  }
126 
136  virtual dwStatus wait(dwTime_t timeout) = 0;
142  virtual void setOnDataReady(void* opaque, IChannelPacketFactory::OnDataReady onDataReady) = 0;
143  };
144 
148  class Producer : public PacketPool
149  {
150  public:
157  virtual dwStatus get(GenericData* data) = 0;
167  virtual dwStatus send(void* data) = 0;
168  };
169 
173  class Consumer : public PacketPool
174  {
175  public:
186  virtual dwStatus recv(GenericData* data) = 0;
197  virtual dwStatus release(void* data) = 0;
198  };
199 
210  virtual Producer* getProducer(GenericDataReference ref) = 0;
211 
221  virtual Consumer* getConsumer(GenericDataReference ref) = 0;
222 
227  virtual bool hasClients() const = 0;
228 
233  virtual bool isConnected() const = 0;
234 
245  virtual dwStatus connect(dwTime_t timeout) = 0;
246 
250  virtual const ChannelParams& getParams() const = 0;
251 };
252 
253 } // namespace framework
254 } // namespace dw
255 
256 #endif // DW_FRAMEWORK_CHANNEL_HPP_
static constexpr dwTime_t CHN_WAIT_TIMEOUT_US
Definition: Channel.hpp:52
virtual Producer * getProducer(GenericDataReference ref)=0
Register a producer client.
virtual bool isConnected() const =0
Query if the channel and its client interfaces are connected to downstream/upstream channels and are ...
Child interface to consume packets on the channel.
Definition: Channel.hpp:173
virtual Consumer * getConsumer(GenericDataReference ref)=0
Register a consumer client.
virtual bool hasClients() const =0
Query if the channel has any clients.
virtual ~ChannelObject()=default
virtual void getSyncObjs(dw::core::span< NvSciSyncObj > &syncObjs)=0
Retrieve the NvSciSyncObjs allocated by the channel.
Definition: Exception.hpp:46
dw::core::Function< void()> OnDataReady
virtual const ChannelParams & getParams() const =0
Get the parameters for this channel.
Child interface to produce packets on the channel.
Definition: Channel.hpp:148
virtual dwStatus connect(dwTime_t timeout)=0
Establish connection over the channel&#39;s protocol.