YARP
Yet Another Robot Platform
PortCoreOutputUnit.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_IMPL_PORTCOREOUTPUTUNIT_H
8#define YARP_OS_IMPL_PORTCOREOUTPUTUNIT_H
9
11#include <yarp/os/Semaphore.h>
14
15#include <mutex>
16
17namespace yarp::os::impl {
18
24 public PortCoreUnit
25{
26public:
35 PortCoreOutputUnit(PortCore& owner, int index, OutputProtocol* op);
36
40 ~PortCoreOutputUnit() override;
41
46 bool start() override;
47
51 void run() override;
52
56 virtual void runSingleThreaded();
57
58 // documented in PortCoreUnit
59 bool isOutput() override
60 {
61 return true;
62 }
63
64 // documented in PortCoreUnit
65 void close() override
66 {
67 closeMain();
68 }
69
70 // documented in PortCoreUnit
71 bool isFinished() override
72 {
73 return finished;
74 }
75
76 const std::string& getName()
77 {
78 return name;
79 }
80
81 // documented in PortCoreUnit
82 Route getRoute() override;
83
84 // documented in PortCoreUnit
85 void* send(const yarp::os::PortWriter& writer,
87 const yarp::os::PortWriter* callback,
88 void* tracker,
89 const std::string& envelopeString,
90 bool waitAfter,
91 bool waitBefore,
92 bool* gotReply) override;
93
94 // documented in PortCoreUnit
95 void* takeTracker() override;
96
97 // documented in PortCoreUnit
98 bool isBusy() override;
99
100 // documented in PortCoreUnit
101 void setCarrierParams(const yarp::os::Property& params) override;
102
103 // documented in PortCoreUnit
104 void getCarrierParams(yarp::os::Property& params) override;
105
106 // return the protocol object
108
109private:
110 OutputProtocol *op;
111 bool closing;
112 bool finished;
113 bool running;
114 bool threaded;
115 bool sending;
116 std::string name;
117 yarp::os::Semaphore phase;
118 yarp::os::Semaphore activate;
119 std::mutex trackerMutex;
120 const yarp::os::PortWriter* cachedWriter;
121 yarp::os::PortReader *cachedReader;
122 const yarp::os::PortWriter* cachedCallback;
124 void *cachedTracker;
125 std::string cachedEnvelope;
126
130 bool sendHelper();
131
135 void closeBasic();
136
140 void closeMain();
141};
142
143} // namespace yarp::os::impl
144
145#endif // YARP_OS_IMPL_PORTCOREOUTPUTUNIT_H
The output side of an active connection between two ports.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition: PortWriter.h:23
A class for storing options and configuration information.
Definition: Property.h:33
Information about a connection between two ports.
Definition: Route.h:28
A class for thread synchronization and mutual exclusion.
Definition: Semaphore.h:25
Manager for a single output from a port.
void getCarrierParams(yarp::os::Property &params) override
void * takeTracker() override
Reacquire a tracker previously passed via send().
void setCarrierParams(const yarp::os::Property &params) override
Set arbitrary parameters for this connection.
void * send(const yarp::os::PortWriter &writer, yarp::os::PortReader *reader, const yarp::os::PortWriter *callback, void *tracker, const std::string &envelopeString, bool waitAfter, bool waitBefore, bool *gotReply) override
Send a message on the connection.
PortCoreOutputUnit(PortCore &owner, int index, OutputProtocol *op)
Constructor.
bool start() override
Prepare to serve this output.
void run() override
The body of a thread managing background sends.
virtual void runSingleThreaded()
Perform send operations without a separate thread.
This manages a single threaded resource related to a single input or output connection.
Definition: PortCoreUnit.h:25
The components from which ports and connections are built.