Let keep-alive tokens be destroyed from any thread
[folly.git] / folly / io / async / EventHandler.h
index 18493304055d15daffaf47958b67a7019aeead7b..59be7bf9a7aacd407960c3e7810f9083ca34fe34 100644 (file)
@@ -1,29 +1,28 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2004-present Facebook, Inc.
  *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
+
 #pragma once
 
+#include <cstddef>
+
+#include <boost/noncopyable.hpp>
 #include <glog/logging.h>
+
 #include <folly/io/async/EventUtil.h>
-#include <boost/noncopyable.hpp>
-#include <stddef.h>
+#include <folly/portability/Event.h>
 
 namespace folly {
 
@@ -43,7 +42,11 @@ class EventHandler : private boost::noncopyable {
     READ = EV_READ,
     WRITE = EV_WRITE,
     READ_WRITE = (READ | WRITE),
-    PERSIST = EV_PERSIST
+    PERSIST = EV_PERSIST,
+// Temporary flag until EPOLLPRI is upstream on libevent.
+#ifdef EV_PRI
+    PRI = EV_PRI,
+#endif
   };
 
   /**
@@ -147,8 +150,7 @@ class EventHandler : private boost::noncopyable {
    * Return the set of events that we're currently registered for.
    */
   uint16_t getRegisteredEvents() const {
-    return (isHandlerRegistered()) ?
-      event_.ev_events : 0;
+    return (isHandlerRegistered()) ? uint16_t(event_.ev_events) : 0u;
   }
 
   /**
@@ -177,10 +179,10 @@ class EventHandler : private boost::noncopyable {
 
   void setEventBase(EventBase* eventBase);
 
-  static void libeventCallback(int fd, short events, void* arg);
+  static void libeventCallback(libevent_fd_t fd, short events, void* arg);
 
   struct event event_;
   EventBase* eventBase_;
 };
 
-} // folly
+} // namespace folly