Commit 0284ef09 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

upstream libfnord changes

parent 69ae93f6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -53,6 +53,12 @@ std::string inspect<long>(
  return std::to_string(value);
}

template <>
std::string inspect<unsigned short>(
    const unsigned short& value) {
  return std::to_string(value);
}

template <>
std::string inspect<float>(const float& value) {
  return std::to_string(value);
+8 −0
Original line number Diff line number Diff line
@@ -30,6 +30,14 @@ public:
    return data_;
  }

  inline void* begin() const {
    return data_;
  }

  inline void* end() const {
    return ((char *) data_) + size_;
  }

  inline void* ptr() const {
    return data_;
  }
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,12 @@ std::string StringUtil::toString(unsigned value) {
  return std::to_string(value);
}

template <>
std::string StringUtil::toString(unsigned short value) {
  return std::to_string(value);
}


template <>
std::string StringUtil::toString(long value) {
  return std::to_string(value);
+8 −3
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ void EventLoop::setupRunQWakeupPipe() {
    max_fd_ = runq_wakeup_pipe_[0];
  }

  callbacks_[runq_wakeup_pipe_[0]] = std::bind(&EventLoop::runQWakeup, this);
  callbacks_[runq_wakeup_pipe_[0]] = std::bind(&EventLoop::onRunQWakeup, this);
}

void EventLoop::run(std::function<void()> task) {
@@ -69,7 +69,7 @@ void EventLoop::appendToRunQ(std::function<void()> task) {
  std::unique_lock<std::mutex> lk(runq_mutex_);
  runq_.emplace_back(task);
  lk.unlock();
  write(runq_wakeup_pipe_[1], "\x0", 1);
  wakeup();
}

void EventLoop::runOnReadable(std::function<void()> task, int fd) {
@@ -154,6 +154,10 @@ void EventLoop::poll() {
  }
}

void EventLoop::wakeup() {
  write(runq_wakeup_pipe_[1], "\x0", 1);
}

void EventLoop::runOnWakeup(
    std::function<void()> task,
    Wakeup* wakeup,
@@ -163,7 +167,7 @@ void EventLoop::runOnWakeup(
  });
}

void EventLoop::runQWakeup() {
void EventLoop::onRunQWakeup() {
  FD_SET(runq_wakeup_pipe_[0], &op_read_);

  static char devnull[512];
@@ -190,6 +194,7 @@ void EventLoop::run() {

void EventLoop::shutdown() {
  running_ = false;
  wakeup();
}

}
+3 −1
Original line number Diff line number Diff line
@@ -35,9 +35,11 @@ public:

protected:

  void wakeup();

  void poll();
  void setupRunQWakeupPipe();
  void runQWakeup();
  void onRunQWakeup();
  void appendToRunQ(std::function<void()> task);

  fd_set op_read_;