proxygen
AsyncSignalHandler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
20 #include <map>
21 
22 namespace folly {
23 
44  public:
48  explicit AsyncSignalHandler(EventBase* eventBase);
49  virtual ~AsyncSignalHandler();
50 
58  void attachEventBase(EventBase* eventBase);
59 
66  void detachEventBase();
67 
72  return eventBase_;
73  }
74 
85  void registerSignalHandler(int signum);
86 
92  void unregisterSignalHandler(int signum);
93 
102  virtual void signalReceived(int signum) noexcept = 0;
103 
104  private:
105  typedef std::map<int, struct event> SignalEventMap;
106 
107  // Forbidden copy constructor and assignment operator
110 
111  static void libeventCallback(libevent_fd_t signum, short events, void* arg);
112 
114  SignalEventMap signalEvents_;
115 };
116 
117 } // namespace folly
static void libeventCallback(libevent_fd_t signum, short events, void *arg)
AsyncSignalHandler & operator=(AsyncSignalHandler const &)
void attachEventBase(EventBase *eventBase)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
EventBase * getEventBase() const
void registerSignalHandler(int signum)
virtual void signalReceived(int signum) noexcept=0
std::map< int, struct event > SignalEventMap
void unregisterSignalHandler(int signum)
int libevent_fd_t
Definition: Event.h:37
AsyncSignalHandler(EventBase *eventBase)