system/Event{FD,Pipe}: throw exception on error
This commit is contained in:
parent
148c38fbb9
commit
0c1a001622
@ -116,7 +116,11 @@ class EventLoop final : SocketMonitor
|
|||||||
ThreadId thread = ThreadId::Null();
|
ThreadId thread = ThreadId::Null();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Throws on error.
|
||||||
|
*/
|
||||||
explicit EventLoop(ThreadId _thread);
|
explicit EventLoop(ThreadId _thread);
|
||||||
|
|
||||||
EventLoop():EventLoop(ThreadId::GetCurrent()) {}
|
EventLoop():EventLoop(ThreadId::GetCurrent()) {}
|
||||||
|
|
||||||
~EventLoop() noexcept;
|
~EventLoop() noexcept;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#ifdef USE_EVENTFD
|
#ifdef USE_EVENTFD
|
||||||
#include "EventFD.hxx"
|
#include "EventFD.hxx"
|
||||||
#include "system/FatalError.hxx"
|
#include "system/Error.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
EventFD::EventFD()
|
EventFD::EventFD()
|
||||||
{
|
{
|
||||||
if (!fd.CreateEventFD(0))
|
if (!fd.CreateEventFD(0))
|
||||||
FatalSystemError("eventfd() failed");
|
throw MakeErrno("eventfd() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@ -25,13 +25,14 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that wraps eventfd().
|
* A class that wraps eventfd().
|
||||||
*
|
|
||||||
* Errors in the constructor are fatal.
|
|
||||||
*/
|
*/
|
||||||
class EventFD {
|
class EventFD {
|
||||||
UniqueFileDescriptor fd;
|
UniqueFileDescriptor fd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Throws on error.
|
||||||
|
*/
|
||||||
EventFD();
|
EventFD();
|
||||||
|
|
||||||
int Get() const {
|
int Get() const {
|
||||||
|
@ -31,7 +31,11 @@ class EventPipe {
|
|||||||
int fds[2];
|
int fds[2];
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
* Throws on error.
|
||||||
|
*/
|
||||||
EventPipe();
|
EventPipe();
|
||||||
|
|
||||||
~EventPipe();
|
~EventPipe();
|
||||||
|
|
||||||
EventPipe(const EventPipe &other) = delete;
|
EventPipe(const EventPipe &other) = delete;
|
||||||
|
Loading…
Reference in New Issue
Block a user