+ SocketThread* parent;
+ public:
+ ThreadSignalSocket(SocketThread* p, int newfd) : parent(p)
+ {
+ SetFd(newfd);
+ ServerInstance->SE->AddFd(this, FD_WANT_FAST_READ | FD_WANT_NO_WRITE);
+ }
+
+ ~ThreadSignalSocket()
+ {
+ ServerInstance->SE->DelFd(this);
+ ServerInstance->SE->Close(GetFd());
+ }
+
+ void Notify()
+ {
+ eventfd_write(fd, 1);
+ }
+
+ void HandleEvent(EventType et, int errornum)
+ {
+ if (et == EVENT_READ)
+ {
+ eventfd_t dummy;
+ eventfd_read(fd, &dummy);
+ parent->OnNotify();
+ }
+ else
+ {
+ ServerInstance->GlobalCulls.AddItem(this);
+ }
+ }
+};
+
+SocketThread::SocketThread()
+{
+ signal.sock = NULL;
+ int fd = eventfd(0, EFD_NONBLOCK);
+ if (fd < 0)
+ throw new CoreException("Could not create pipe " + std::string(strerror(errno)));
+ signal.sock = new ThreadSignalSocket(this, fd);