33 name(owner.getName()),
37 cachedWriter(nullptr),
38 cachedReader(nullptr),
39 cachedCallback(nullptr),
40 cachedTracker(nullptr)
98 if (cachedTracker !=
nullptr) {
99 void* t = cachedTracker;
100 cachedTracker =
nullptr;
106 trackerMutex.unlock();
135 info.incoming =
false;
148void PortCoreOutputUnit::closeBasic()
172 std::string msg = std::string(
"Removing output from ") + route.
getFromName() +
" to " + route.
getToName();
186 info.incoming =
false;
187 info.created =
false;
202 is.
read(dummy.bytes());
211void PortCoreOutputUnit::closeMain()
253bool PortCoreOutputUnit::sendHelper()
260 if (cachedReader !=
nullptr) {
261 buf.setReplyHandler(*cachedReader);
264 if (op->
getSender().modifiesOutgoingData()) {
265 if (op->
getSender().acceptOutgoingData(*cachedWriter)) {
266 cachedWriter = &op->
getSender().modifyOutgoingData(*cachedWriter);
268 return (done =
true);
286 bool ok = cachedWriter->
write(buf);
291 bool suppressReply = (buf.getReplyHandler() ==
nullptr);
295 if (!cachedEnvelope.empty()) {
301 if (!cachedEnvelope.empty()) {
302 if (cachedEnvelope ==
"__ADMIN") {
306 PortCommand pc(
'\0', std::string(suppressReply ?
"D " :
"d ") + cachedEnvelope);
320 if (
replied && op->
getSender().modifiesReply() && cachedReader !=
nullptr) {
321 cachedReader = &op->
getSender().modifyReply(*cachedReader);
329 if (buf.dropRequested()) {
375 cachedWriter = &writer;
376 cachedReader = reader;
377 cachedCallback = callback;
390 trackerMutex.unlock();
413 cachedTracker =
nullptr;
415 trackerMutex.unlock();
A mini-server for performing network communication in the background.
void write(bool forceStrict=false)
Write the current object being returned by BufferedPort::prepare.
An abstraction for a block of bytes, with optional responsibility for allocating/destroying that bloc...
Simple abstraction for a YARP port name.
bool isRooted() const
Check if port name begins with "/".
static int disconnectInput(const std::string &src, const std::string &dest, bool silent=false)
Sends a disconnection command to the specified port.
The output side of an active connection between two ports.
virtual Connection & getConnection()=0
Get the connection whose protocol operations we are managing.
virtual const Route & getRoute() const =0
virtual void close()=0
Negotiate an end to operations.
virtual void interrupt()=0
virtual InputStream & getInputStream()=0
Access the input stream associated with the connection.
virtual Connection & getSender()=0
It is possible to chain a basic connection with a modifier.
virtual void beginWrite()=0
Notify connection that we intend to write to it.
virtual bool isOk() const =0
Check if the connection is valid and can be used.
virtual bool write(SizedWriter &writer)=0
Write a message on the connection.
Information about a port connection or event.
std::string message
A human-readable description of contents.
@ PORTINFO_CONNECTION
Information about an incoming or outgoing connection.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
This is a base class for objects that can be both read from and be written to the YARP network.
A class for storing options and configuration information.
Information about a connection between two ports.
const std::string & getToName() const
Get the destination of the route.
const std::string & getCarrierName() const
Get the carrier type of the route.
std::string toString() const
Render a text form of the route, "source->carrier->dest".
const std::string & getFromName() const
Get the source of the route.
void wait()
Decrement the counter, even if we must wait to do that.
void post()
Increment the counter.
A helper for creating cached object descriptions.
Simple Readable and Writable object representing a command to a YARP port.
OutputProtocol * getOutPutProtocol()
void getCarrierParams(yarp::os::Property ¶ms) override
void * takeTracker() override
Reacquire a tracker previously passed via send().
void setCarrierParams(const yarp::os::Property ¶ms) 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() override
Destructor.
const std::string & getName()
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.
Route getRoute() override
This manages a single threaded resource related to a single input or output connection.
void setMode()
Check the carrier used for the connection, and see if it has a "log" modifier.
void setDoomed()
Request that this connection be shut down as soon as possible.
void notifyCompletion(void *tracker)
Call the right onCompletion() after sending message.
void report(const yarp::os::PortInfo &info)
Handle a port event (connection, disconnection, etc) Generate a description of the connections associ...
void reportUnit(PortCoreUnit *unit, bool active)
Called by a connection handler with active=true just after it is fully configured,...
int join(double seconds=-1)
#define yCIAssert(component, id, x)
#define yCIError(component, id,...)
#define yCIInfo(component, id,...)
#define yCIDebug(component, id,...)
#define YARP_OS_LOG_COMPONENT(name, name_string)
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.