Make NotificationQueue::Consumer::messageAvailable noexcept
authorAlan Frindell <afrind@fb.com>
Wed, 5 Apr 2017 23:37:16 +0000 (16:37 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Wed, 5 Apr 2017 23:51:06 +0000 (16:51 -0700)
Summary: There's a comment in that code that states that it *it* noexcept, and that is common for most folly async io callbacks.

Reviewed By: yfeldblum

Differential Revision: D4831800

fbshipit-source-id: 78894ad72504b9dfe540c14b8d7bbb29247aaf87

folly/io/async/AsyncServerSocket.cpp
folly/io/async/AsyncServerSocket.h
folly/io/async/EventBase.cpp
folly/io/async/NotificationQueue.h
folly/io/async/test/NotificationQueueTest.cpp

index dc6b4b6c6411050afad320f822f69efd6e5362a0..7e02dde7e19ae5d6e796a65fe16bdce698398c50 100644 (file)
@@ -90,8 +90,7 @@ void AsyncServerSocket::RemoteAcceptor::stop(
 }
 
 void AsyncServerSocket::RemoteAcceptor::messageAvailable(
-  QueueMessage&& msg) {
-
+    QueueMessage&& msg) noexcept {
   switch (msg.type) {
     case MessageType::MSG_NEW_CONN:
     {
index f509cbc68e14838b320477f0af6800970ffb9739..63ca06ed2007ae8d58a24a358d6b3b6dd167875b 100644 (file)
@@ -755,7 +755,7 @@ class AsyncServerSocket : public DelayedDestruction
     void start(EventBase *eventBase, uint32_t maxAtOnce, uint32_t maxInQueue);
     void stop(EventBase* eventBase, AcceptCallback* callback);
 
-    virtual void messageAvailable(QueueMessage&& message);
+    virtual void messageAvailable(QueueMessage&& message) noexcept override;
 
     NotificationQueue<QueueMessage>* getQueue() {
       return &queue_;
index 1f5ea560f61a34737f1eedfaad3ff142dd717f0d..895e1a4959b2afb16728783c60f55fdb63d89578 100644 (file)
@@ -40,7 +40,7 @@ namespace folly {
 class EventBase::FunctionRunner
     : public NotificationQueue<EventBase::Func>::Consumer {
  public:
-  void messageAvailable(Func&& msg) override {
+  void messageAvailable(Func&& msg) noexcept override {
     // In libevent2, internal events do not break the loop.
     // Most users would expect loop(), followed by runInEventBaseThread(),
     // to break the loop and check if it should exit or not.
index f27b17f5b98043d74febd1d36c02f7653272cde8..28a2878eb81ecde122f68b5e440d870bdb0859bc 100644 (file)
@@ -88,7 +88,7 @@ class NotificationQueue {
      * 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.
@@ -855,7 +855,7 @@ struct notification_queue_consumer_wrapper
       : 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 {}`"
index 465da1d365b13e8cb2e8ae70d6ab009d1c2789e5..7e5d9827d7d82dbac3aed22f3ec39b53a8b4b002 100644 (file)
@@ -38,7 +38,7 @@ class QueueConsumer : public IntQueue::Consumer {
  public:
   QueueConsumer() {}
 
-  void messageAvailable(int&& value) override {
+  void messageAvailable(int&& value) noexcept override {
     messages.push_back(value);
     if (fn) {
       fn(value);
@@ -360,7 +360,7 @@ void QueueTest::destroyCallback() {
   // avoid destroying the function object.
   class DestroyTestConsumer : public IntQueue::Consumer {
    public:
-    void messageAvailable(int&& value) override {
+    void messageAvailable(int&& value) noexcept override {
       DestructorGuard g(this);
       if (fn && *fn) {
         (*fn)(value);