libzypp  17.35.14
wakeup.cpp
Go to the documentation of this file.
1 #include "wakeup.h"
2 
4 #include <zypp-core/zyppng/base/SocketNotifier>
5 
6 #include <unistd.h>
7 #include <fcntl.h>
8 
9 namespace zyppng {
10 
12  {
13  ::pipe ( _wakeupPipe );
14  ::fcntl( _wakeupPipe[0], F_SETFL, O_NONBLOCK );
15  }
16 
18  {
19  ::close (_wakeupPipe[0]);
20  ::close (_wakeupPipe[1]);
21  }
22 
24  {
25  eintrSafeCall( ::write, _wakeupPipe[1], "\n", 1);
26  }
27 
28  void Wakeup::ack()
29  {
30  char dummy = 0;
31  while ( eintrSafeCall( ::read, _wakeupPipe[0], &dummy, 1 ) > 0 ) { continue; }
32  }
33 
34  int Wakeup::pollfd() const
35  {
36  return _wakeupPipe[0];
37  }
38 
39  std::shared_ptr<SocketNotifier> Wakeup::makeNotifier( const bool enabled ) const
40  {
42  }
43 
44 }
static Ptr create(int socket, int evTypes, bool enable=true)
void ack()
Definition: wakeup.cpp:28
int pollfd() const
Definition: wakeup.cpp:34
std::shared_ptr< SocketNotifier > makeNotifier(const bool enabled=true) const
Definition: wakeup.cpp:39
void notify()
Definition: wakeup.cpp:23
int _wakeupPipe[2]
Definition: wakeup.h:51
auto eintrSafeCall(Fun &&function, Args &&... args)
std::map< std::string, std::string > read(const Pathname &_path)
Read sysconfig file path_r and return (key,valye) pairs.
Definition: sysconfig.cc:34
bool write(const Pathname &path_r, const std::string &key_r, const std::string &val_r, const std::string &newcomment_r)
Add or change a value in sysconfig file path_r.
Definition: sysconfig.cc:80