#include <glog/logging.h>
#include <folly/FileUtil.h>
+#include <folly/Singleton.h>
#include <folly/portability/Sockets.h>
namespace folly {
+namespace {
+struct PrivateTag {};
+folly::Singleton<folly::ShutdownSocketSet, PrivateTag> singleton;
+} // namespace
+
ShutdownSocketSet::ShutdownSocketSet(int maxFd)
: maxFd_(maxFd),
data_(static_cast<std::atomic<uint8_t>*>(
folly::checkedCalloc(size_t(maxFd), sizeof(std::atomic<uint8_t>)))),
nullFile_("/dev/null", O_RDWR) {}
+std::shared_ptr<ShutdownSocketSet> ShutdownSocketSet::getInstance() {
+ return singleton.try_get();
+}
+
void ShutdownSocketSet::add(int fd) {
// Silently ignore any fds >= maxFd_, very unlikely
DCHECK_GE(fd, 0);