libzypp 17.37.17
|
#include <zypp-core/zyppng/io/asyncdatasource.h>
Public Types | |
enum | ChannelCloseReason { RemoteClose , AccessError , InternalError , UserRequest } |
using | Ptr = std::shared_ptr<AsyncDataSource> |
using | WeakPtr = std::weak_ptr<AsyncDataSource> |
Public Types inherited from zyppng::IODevice | |
enum | OpenModeFlag { Closed = 0x0 , ReadOnly = 0x1 , WriteOnly = 0x2 , ReadWrite = ReadOnly | WriteOnly } |
using | Ptr = std::shared_ptr<IODevice> |
using | WeakPtr = std::weak_ptr<IODevice> |
Public Types inherited from zyppng::Base | |
using | Ptr = std::shared_ptr<Base> |
using | WeakPtr = std::weak_ptr<Base> |
Public Member Functions | |
bool | openFds (const std::vector< int > &readFds, int writeFd=-1) |
void | close () override |
virtual void | closeWriteChannel () |
bool | waitForReadyRead (uint channel, int timeout) override |
void | flush () |
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> | sigWriteFdClosed () |
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> | sigReadFdClosed () |
bool | readFdOpen () const |
bool | readFdOpen (uint channel) const |
int64_t | bytesPending () const override |
bool | waitForReadyRead (int timeout) |
Public Member Functions inherited from zyppng::IODevice | |
ZYPP_DECLARE_FLAGS (OpenMode, OpenModeFlag) | |
IODevice () | |
void | setReadChannel (uint channel) |
uint | currentReadChannel () const |
int | readChannelCount () const |
bool | canRead () const |
bool | canWrite () const |
bool | isOpen () const |
ByteArray | readAll () |
ByteArray | read (int64_t maxSize) |
int64_t | read (char *buf, int64_t maxSize) |
virtual ByteArray | readLine (const int64_t maxSize=0) |
virtual int64_t | bytesAvailable () const |
int64_t | readBufferCount () const |
bool | canReadLine () const |
ByteArray | readAll (uint channel) |
ByteArray | read (uint channel, int64_t maxSize) |
int64_t | read (uint channel, char *buf, int64_t maxSize) |
ByteArray | channelReadUntil (uint channel, const char delim, int64_t maxSize=0) |
ByteArray | channelReadLine (uint channel, int64_t maxSize=0) |
int64_t | channelReadLine (uint channel, char *buf, const int64_t maxSize) |
virtual int64_t | bytesAvailable (uint channel) const |
int64_t | readBufferCount (uint channel) const |
virtual int64_t | channelReadUntil (uint channel, char *buf, const char delimiter, const int64_t maxSize) |
bool | canReadLine (uint channel) const |
bool | canReadUntil (uint channel, const char delim) const |
int64_t | write (const ByteArray &data) |
int64_t | write (const char *data, int64_t len) |
bool | waitForReadyRead (int timeout) |
SignalProxy< void()> | sigReadyRead () |
SignalProxy< void(uint)> | sigChannelReadyRead () |
SignalProxy< void(int64_t)> | sigBytesWritten () |
SignalProxy< void()> | sigAllBytesWritten () |
SignalProxy< void(uint) > | sigReadChannelFinished () |
Public Member Functions inherited from zyppng::Base | |
Base () | |
virtual | ~Base () |
WeakPtr | parent () const |
void | addChild (const Base::Ptr &child) |
void | removeChild (const Ptr &child) |
const std::unordered_set< Ptr > & | children () const |
std::thread::id | threadId () const |
template<typename T> | |
std::vector< std::weak_ptr< T > > | findChildren () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () const |
template<typename T> | |
std::shared_ptr< T > | shared_this () |
template<typename T> | |
std::weak_ptr< T > | weak_this () const |
template<typename T> | |
std::weak_ptr< T > | weak_this () |
template<typename SenderFunc, typename ReceiverFunc> | |
auto | connect (SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
std::enable_if_t< std::is_member_function_pointer_v< SenderFunc >, connection > | connectFunc (SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
Static Public Member Functions | |
static Ptr | create () |
Static Public Member Functions inherited from zyppng::Base | |
template<typename Obj, typename Functor> | |
static decltype(auto) | make_base_slot (Obj *o, Functor &&f) |
template<typename SenderFunc, typename ReceiverFunc> | |
static auto | connect (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, typename internal::MemberFunction< ReceiverFunc >::ClassType &recv, ReceiverFunc &&rFunc) |
template<typename SenderFunc, typename ReceiverFunc, typename ... Tracker> | |
static auto | connectFunc (typename internal::MemberFunction< SenderFunc >::ClassType &s, SenderFunc &&sFun, ReceiverFunc &&rFunc, const Tracker &...trackers) |
Protected Member Functions | |
AsyncDataSource () | |
AsyncDataSource (AsyncDataSourcePrivate &d) | |
int64_t | writeData (const char *data, int64_t count) override |
Protected Member Functions inherited from zyppng::IODevice | |
IODevice (IODevicePrivate &d) | |
void | setReadChannelCount (uint channels) |
void | finishReadChannel (uint channel) |
Protected Member Functions inherited from zyppng::Base | |
Base (BasePrivate &dd) |
Private Member Functions | |
int64_t | readData (uint channel, char *buffer, int64_t bufsize) override |
int64_t | rawBytesAvailable (uint channel) const override |
void | readChannelChanged (uint channel) override |
virtual bool | open (const OpenMode mode) |
Additional Inherited Members | |
Protected Attributes inherited from zyppng::Base | |
std::unique_ptr< BasePrivate > | d_ptr |
Definition at line 11 of file asyncdatasource.h.
using zyppng::AsyncDataSource::Ptr = std::shared_ptr<AsyncDataSource> |
Definition at line 23 of file asyncdatasource.h.
using zyppng::AsyncDataSource::WeakPtr = std::weak_ptr<AsyncDataSource> |
Definition at line 24 of file asyncdatasource.h.
Enumerator | |
---|---|
RemoteClose | |
AccessError | |
InternalError | |
UserRequest |
Definition at line 16 of file asyncdatasource.h.
|
protected |
Definition at line 139 of file asyncdatasource.cpp.
|
protected |
Definition at line 142 of file asyncdatasource.cpp.
|
static |
Definition at line 146 of file asyncdatasource.cpp.
bool zyppng::AsyncDataSource::openFds | ( | const std::vector< int > & | readFds, |
int | writeFd = -1 ) |
Borrows the given fd's and starts reading/writing to them if data is available. Note that AsyncDataSource does not take ownership of the FDs, they need to be closed explicitely after they were released with close
Definition at line 152 of file asyncdatasource.cpp.
|
overridevirtual |
Closes the AsyncDataSource and releases the used fd's to the calling code. They are NOT closed.
Reimplemented from zyppng::IODevice.
Reimplemented in zyppng::Process.
Definition at line 260 of file asyncdatasource.cpp.
|
virtual |
Reimplemented in zyppng::Process.
Definition at line 283 of file asyncdatasource.cpp.
|
overridevirtual |
Blocks the current event loop to wait until all bytes currently in the buffer have been written to the write fd.
Implements zyppng::IODevice.
Definition at line 303 of file asyncdatasource.cpp.
void zyppng::AsyncDataSource::flush | ( | ) |
Blocks the current event loop to wait until all bytes currently in the buffer have been written to the write fd.
Definition at line 334 of file asyncdatasource.cpp.
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> zyppng::AsyncDataSource::sigWriteFdClosed | ( | ) |
Signal is emitted always when the write channel is closed. All data that was not written yet will be discarded and canWrite() will return false.
Definition at line 353 of file asyncdatasource.cpp.
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> zyppng::AsyncDataSource::sigReadFdClosed | ( | ) |
Signal is emitted always when the write channel is closed, for example when the write side of a pipe is closed. All data still residing in the read buffer can still be read.
Definition at line 358 of file asyncdatasource.cpp.
bool zyppng::AsyncDataSource::readFdOpen | ( | ) | const |
Returns true as long as the default read channel was not closed ( e.g. sigReadFdClosed was emitted )
Definition at line 363 of file asyncdatasource.cpp.
bool zyppng::AsyncDataSource::readFdOpen | ( | uint | channel | ) | const |
Returns true as long as the given read channel was not closed ( e.g. sigReadFdClosed was emitted )
Definition at line 371 of file asyncdatasource.cpp.
|
overridevirtual |
Returns the current number of bytes that are not yet written to the data source.
Implements zyppng::IODevice.
Definition at line 382 of file asyncdatasource.cpp.
|
overrideprotectedvirtual |
Implements zyppng::IODevice.
Definition at line 203 of file asyncdatasource.cpp.
|
overrideprivatevirtual |
Implements zyppng::IODevice.
Definition at line 214 of file asyncdatasource.cpp.
|
overrideprivatevirtual |
Implements zyppng::IODevice.
Definition at line 237 of file asyncdatasource.cpp.
|
overrideprivatevirtual |
Implements zyppng::IODevice.
Definition at line 251 of file asyncdatasource.cpp.
bool zyppng::IODevice::waitForReadyRead | ( | int | timeout | ) |
Blocks the current event loop to wait until there are bytes available to read from the device. This always operates on the read channel that is selected as the default when the function is first called, even if the default channel would be changed during the wait.
Definition at line 141 of file iodevice.cc.
|
privatevirtual |
Reimplemented from zyppng::IODevice.
Definition at line 180 of file iodevice.cc.