libzypp  17.34.1
asyncdatasource.h
Go to the documentation of this file.
1 #ifndef ASYNCDATASOURCE_H
2 #define ASYNCDATASOURCE_H
3 
4 #include <zypp-core/zyppng/base/Base>
5 #include <zypp-core/zyppng/io/IODevice>
6 
7 namespace zyppng {
8 
9  class AsyncDataSourcePrivate;
10 
11  class AsyncDataSource : public IODevice
12  {
14  public:
15 
17  RemoteClose, // the other side of the fd was closed
18  AccessError, // we got an EACCESS when polling the fd
19  InternalError, // we got a unexpected errno when polling the fd
20  UserRequest // channel were closed because close() was called
21  };
22 
23  using Ptr = std::shared_ptr<AsyncDataSource>;
24  using WeakPtr = std::weak_ptr<AsyncDataSource>;
25 
26  static Ptr create ();
27  bool openFds ( const std::vector<int>& readFds, int writeFd = -1 );
28  void close () override;
29 
31 
32  virtual void closeWriteChannel ();
33 
40  bool waitForReadyRead(uint channel, int timeout) override;
41 
48  void flush ();
49 
56 
63 
67  bool readFdOpen () const;
68 
72  bool readFdOpen ( uint channel ) const;
73 
74  protected:
75  AsyncDataSource ( );
77  int64_t writeData(const char *data, int64_t count) override;
78 
79  private:
80  using IODevice::open;
81 
82  int64_t readData( uint channel, char *buffer, int64_t bufsize ) override;
83  int64_t rawBytesAvailable( uint channel ) const override;
84  void readChannelChanged ( uint channel ) override;
85  };
86 }
87 
88 
89 #endif // ASYNCDATASOURCE_H
std::weak_ptr< Base > WeakPtr
Definition: base.h:66
SignalProxy< void(AsyncDataSource::ChannelCloseReason)> sigWriteFdClosed()
virtual bool open(const OpenMode mode)
Definition: iodevice.cc:16
SignalProxy< void(uint, AsyncDataSource::ChannelCloseReason)> sigReadFdClosed()
int64_t rawBytesAvailable(uint channel) const override
int64_t writeData(const char *data, int64_t count) override
void readChannelChanged(uint channel) override
virtual void closeWriteChannel()
int64_t readData(uint channel, char *buffer, int64_t bufsize) override
bool openFds(const std::vector< int > &readFds, int writeFd=-1)
ZYPP_DECLARE_PRIVATE(AsyncDataSource)
bool waitForReadyRead(int timeout)
Definition: iodevice.cc:315
std::shared_ptr< Base > Ptr
Definition: base.h:65
bool waitForReadyRead(uint channel, int timeout) override