bool
LogCatReader::OnFileEvent(int _fd, unsigned mask)
{
  assert(_fd == fd.Get());

  char buffer[1024];
  ssize_t nbytes = fd.Read(buffer, sizeof(buffer));
  if (nbytes > 0) {
    if (data.length() < 1024 * 1024)
      data.append(buffer, nbytes);
    return true;
  } else {
    EndOfFile();
    return false;
  }
}
  ~LogCatReader() {
    io_thread.LockRemove(fd.Get());
    fd.Close();

    Kill(pid.exchange(0));
  }
 LogCatReader(IOThread &_io_thread, FileDescriptor &&_fd, pid_t _pid)
   :io_thread(_io_thread), fd(std::move(_fd)), pid(_pid) {
   io_thread.LockAdd(fd.Get(), IOThread::READ, *this);
 }
Beispiel #4
0
 gcc_pure
 bool operator()(const File &a, FileDescriptor b) const {
   return a.fd.Get() < b.Get();
 }
Beispiel #5
0
 gcc_pure
 bool operator()(FileDescriptor a, const File &b) const {
   return a.Get() < b.fd.Get();
 }
Beispiel #6
0
 /**
  * Returns the file descriptor that should be polled on.
  */
 int GetReadFD() const {
   return r.Get();
 }