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();
121 std::shared_ptr<OutputProtocol>
localOp = op;
139 info.incoming =
false;
152void PortCoreOutputUnit::closeBasic()
159 std::shared_ptr<OutputProtocol>
localOp = op;
162 localOp->getConnection().prepareDisconnect();
164 if (
localOp->getConnection().isConnectionless() ||
localOp->getConnection().isBroadcast()) {
171 if (
localOp->getConnection().canEscape()) {
173 localOp->getConnection().isBareMode());
196 info.incoming =
false;
197 info.created =
false;
209 if (
localOp->getConnection().isTextMode() &&
localOp->getConnection().supportReply()) {
212 is.
read(dummy.bytes());
227void PortCoreOutputUnit::closeMain()
241 std::shared_ptr<OutputProtocol>
localOp = op;
265 std::shared_ptr<OutputProtocol>
localOp = op;
274bool PortCoreOutputUnit::sendHelper()
279 std::shared_ptr<OutputProtocol>
localOp = op;
284 localOp->getConnection().isBareMode());
285 if (cachedReader !=
nullptr) {
286 buf.setReplyHandler(*cachedReader);
289 if (
localOp->getSender().modifiesOutgoingData()) {
290 if (
localOp->getSender().acceptOutgoingData(*cachedWriter)) {
291 cachedWriter = &
localOp->getSender().modifyOutgoingData(*cachedWriter);
293 return (done =
true);
297 if (
localOp->getConnection().isLocal()) {
311 bool ok = cachedWriter->
write(buf);
316 bool suppressReply = (buf.getReplyHandler() ==
nullptr);
319 if (!
localOp->getConnection().canEscape()) {
320 if (!cachedEnvelope.empty()) {
321 localOp->getConnection().handleEnvelope(cachedEnvelope);
326 if (!cachedEnvelope.empty()) {
327 if (cachedEnvelope ==
"__ADMIN") {
331 PortCommand pc(
'\0', std::string(suppressReply ?
"D " :
"d ") + cachedEnvelope);
343 if (
localOp->getConnection().isActive()) {
345 if (
replied &&
localOp->getSender().modifiesReply() && cachedReader !=
nullptr) {
346 cachedReader = &
localOp->getSender().modifyReply(*cachedReader);
354 if (buf.dropRequested()) {
381 std::shared_ptr<OutputProtocol>
localOp = op;
383 if (!
localOp->getConnection().isActive()) {
403 cachedWriter = &writer;
404 cachedReader = reader;
405 cachedCallback = callback;
418 trackerMutex.unlock();
441 cachedTracker =
nullptr;
443 trackerMutex.unlock();
457 std::shared_ptr<OutputProtocol>
localOp = op;
459 localOp->getSender().setCarrierParams(params);
465 std::shared_ptr<OutputProtocol>
localOp = op;
467 localOp->getSender().getCarrierParams(params);
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
void interrupt() override
Interrupt any current reads or writes attached to the port.
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.
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.