#include <stdexcept>
#include <utility>
+#include <folly/Exception.h>
#include <folly/FileUtil.h>
#include <folly/io/async/EventBase.h>
#include <folly/io/async/EventHandler.h>
* messageAvailable() will be invoked whenever a new
* message is available from the pipe.
*/
- virtual void messageAvailable(MessageT&& message) = 0;
+ virtual void messageAvailable(MessageT&& message) noexcept = 0;
/**
* Begin consuming messages from the specified queue.
void destroy() override;
- virtual ~Consumer() {}
+ ~Consumer() override {}
private:
/**
NotificationQueue& operator=(NotificationQueue const &) = delete;
inline bool checkQueueSize(size_t maxSize, bool throws=true) const {
- DCHECK(0 == spinlock_.trylock());
+ DCHECK(0 == spinlock_.try_lock());
if (maxSize > 0 && queue_.size() >= maxSize) {
if (throws) {
throw std::overflow_error("unable to add message to NotificationQueue: "
: callback_(std::forward<UCallback>(callback)) {}
// we are being stricter here and requiring noexcept for callback
- void messageAvailable(MessageT&& message) override {
+ void messageAvailable(MessageT&& message) noexcept override {
static_assert(
noexcept(std::declval<TCallback>()(std::forward<MessageT>(message))),
"callback must be declared noexcept, e.g.: `[]() noexcept {}`"