21PortWriterBufferManager::~PortWriterBufferManager() =
default;
48 yCDebug(PORTWRITERBUFFERBASE,
"finishing writes");
52 if (port !=
nullptr) {
63 completionSema.
wait();
66 yCDebug(PORTWRITERBUFFERBASE,
"finished writes");
71 if (callback !=
nullptr) {
75 yCDebug(PORTWRITERBUFFERBASE,
"releasing unused buffer");
80 yCAssert(PORTWRITERBUFFERBASE, packet !=
nullptr);
82 yCDebug(PORTWRITERBUFFERBASE,
"creating a writer buffer");
84 yarp::os::PortWriterWrapper* wrapper = owner.
create(*
this, packet);
86 packet->
setContent(wrapper->getInternal(),
false, wrapper,
true);
102 if (cback !=
nullptr) {
108 return cback !=
nullptr;
114 yCDebug(PORTWRITERBUFFERBASE,
"freeing up a writer buffer");
117 bool sig = finishing;
121 completionSema.
post();
150 if (active !=
nullptr && port !=
nullptr) {
154 port->
write(*active, cback);
161 std::mutex stateMutex;
163 Port* port {
nullptr};
166 bool finishing {
false};
173PortWriterBufferBase::PortWriterBufferBase() :
190 return mPriv->release();
196 return mPriv->getCount();
211 mPriv->write(strict);
216 mPriv->finishWrites();
void onCompletion(void *tracker) override
Private(PortWriterBufferBase &owner)
const void * getContent() const
virtual ~PortWriterBufferBase()
virtual PortWriterWrapper * create(PortWriterBufferManager &man, void *tracker)=0
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
virtual void onCompletion() const
This is called when the port has finished all writing operations.
A mini-server for network communication.
void enableBackgroundWrite(bool backgroundFlag)
control whether writing from this port is done in the background.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
bool isOpen() const
Check if the port has been opened.
A class for thread synchronization and mutual exclusion.
void wait()
Decrement the counter, even if we must wait to do that.
void post()
Increment the counter.
A single message, potentially being transmitted on multiple connections.
void setContent(const yarp::os::PortWriter *writable, bool owned=false, const yarp::os::PortWriter *callback=nullptr, bool ownedCallback=false)
Configure the object being sent and where to send notifications.
const yarp::os::PortWriter * getContent()
const yarp::os::PortWriter * getCallback()
A collection of messages being transmitted over connections.
PortCorePacket * getFreePacket()
Get a packet that we can prepare for sending.
void freePacket(PortCorePacket *packet, bool clear=true)
Force the given packet into an inactive state.
#define yCAssert(component, x)
#define yCDebug(component,...)
#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.