YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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 <memory>
16#include <mutex>
17
18namespace yarp::os::impl {
19
25 public PortCoreUnit
26{
27public:
36 PortCoreOutputUnit(PortCore& owner, int index, OutputProtocol* op);
37
41 ~PortCoreOutputUnit() override;
42
47 bool start() override;
48
52 void run() override;
53
57 virtual void runSingleThreaded();
58
59 // documented in PortCoreUnit
60 bool isOutput() override
61 {
62 return true;
63 }
64
65 // documented in PortCoreUnit
66 void close() override
67 {
68 closeMain();
69 }
70
71 // documented in PortCoreUnit
72 bool isFinished() override
73 {
74 return finished;
75 }
76
77 const std::string& getName()
78 {
79 return name;
80 }
81
82 // documented in PortCoreUnit
83 Route getRoute() override;
84
85 // documented in PortCoreUnit
86 void* send(const yarp::os::PortWriter& writer,
88 const yarp::os::PortWriter* callback,
89 void* tracker,
90 const std::string& envelopeString,
91 bool waitAfter,
92 bool waitBefore,
93 bool* gotReply) override;
94
95 // documented in PortCoreUnit
96 void* takeTracker() override;
97
98 // documented in PortCoreUnit
99 bool isBusy() override;
100
101 // documented in PortCoreUnit
102 void setCarrierParams(const yarp::os::Property& params) override;
103
104 // documented in PortCoreUnit
105 void getCarrierParams(yarp::os::Property& params) override;
106
107 // return the protocol object
109
110private:
111 std::shared_ptr<OutputProtocol> op;
112 bool closing;
113 bool finished;
114 bool running;
115 bool threaded;
116 bool sending;
117 std::string name;
118 yarp::os::Semaphore phase;
119 yarp::os::Semaphore activate;
120 std::mutex trackerMutex;
121 const yarp::os::PortWriter* cachedWriter;
122 yarp::os::PortReader *cachedReader;
123 const yarp::os::PortWriter* cachedCallback;
125 void *cachedTracker;
126 std::string cachedEnvelope;
127
131 bool sendHelper();
132
136 void closeBasic();
137
141 void closeMain();
142};
143
144} // namespace yarp::os::impl
145
146#endif // YARP_OS_IMPL_PORTCOREOUTPUTUNIT_H
A mini-server for performing network communication in the background.
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.
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.
The components from which ports and connections are built.