summaryrefslogtreecommitdiff
path: root/src/socketengines/socketengine_eventfd.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-08-15 01:45:38 -0400
committerAdam <Adam@anope.org>2010-08-15 01:45:38 -0400
commita950ed8cabfeca55c909f02412b1788bd386dcff (patch)
treecfa9a16c2385176490ea849f6a4041ee9456c8eb /src/socketengines/socketengine_eventfd.cpp
parent4d0a1aaabd861bb7cd1e378bd1e600af1d34d5d2 (diff)
Rewrote the MySQL API to use threads. This acts similar to before, but is faster. Removed db_mysql_execute for now.
Diffstat (limited to 'src/socketengines/socketengine_eventfd.cpp')
-rw-r--r--src/socketengines/socketengine_eventfd.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/socketengines/socketengine_eventfd.cpp b/src/socketengines/socketengine_eventfd.cpp
new file mode 100644
index 000000000..767a6eddb
--- /dev/null
+++ b/src/socketengines/socketengine_eventfd.cpp
@@ -0,0 +1,47 @@
+#include "services.h"
+#include <sys/eventfd.h>
+
+int Pipe::RecvInternal(char *buf, size_t sz) const
+{
+ static eventfd_t dummy;
+ return !eventfd_read(this->Sock, &dummy);
+}
+
+int Pipe::SendInternal(const Anope::string &) const
+{
+ return !eventfd_write(this->Sock, 1);
+}
+
+Pipe::Pipe() : Socket()
+{
+ this->Sock = eventfd(0, EFD_NONBLOCK);
+ if (this->Sock < 0)
+ throw CoreException(Anope::string("Could not create pipe: ") + strerror(errno));
+
+ this->IPv6 = false;
+ this->Type = SOCKTYPE_CLIENT;
+
+ SocketEngine->AddSocket(this);
+}
+
+bool Pipe::ProcessRead()
+{
+ this->RecvInternal(NULL, 0);
+ return this->Read("");
+}
+
+bool Pipe::Read(const Anope::string &)
+{
+ this->OnNotify();
+ return true;
+}
+
+void Pipe::Notify()
+{
+ this->Write("*");
+}
+
+void Pipe::OnNotify()
+{
+}
+