aboutsummaryrefslogtreecommitdiffstats
path: root/src/system/EventFD.cxx
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/system/EventFD.cxx23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/system/EventFD.cxx b/src/system/EventFD.cxx
index 9ac4c1d94..016dd372c 100644
--- a/src/system/EventFD.cxx
+++ b/src/system/EventFD.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2014 The Music Player Daemon Project
+ * Copyright (C) 2003-2015 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -20,46 +20,35 @@
#include "config.h"
#ifdef USE_EVENTFD
#include "EventFD.hxx"
-#include "system/fd_util.h"
#include "system/FatalError.hxx"
#include "Compiler.h"
#include <assert.h>
-#include <unistd.h>
-
#include <sys/eventfd.h>
EventFD::EventFD()
- :fd(eventfd_cloexec_nonblock(0, 0))
{
- if (fd < 0)
+ if (!fd.CreateEventFD(0))
FatalSystemError("eventfd() failed");
}
-EventFD::~EventFD()
-{
- assert(fd >= 0);
-
- close(fd);
-}
-
bool
EventFD::Read()
{
- assert(fd >= 0);
+ assert(fd.IsDefined());
eventfd_t value;
- return read(fd, &value, sizeof(value)) == (ssize_t)sizeof(value);
+ return fd.Read(&value, sizeof(value)) == (ssize_t)sizeof(value);
}
void
EventFD::Write()
{
- assert(fd >= 0);
+ assert(fd.IsDefined());
static constexpr eventfd_t value = 1;
gcc_unused ssize_t nbytes =
- write(fd, &value, sizeof(value));
+ fd.Write(&value, sizeof(value));
}
#endif /* USE_EVENTFD */