event/SocketEvent: allow Cancel() without socket
This commit is contained in:
parent
653eea5840
commit
7901b04c78
@ -38,12 +38,6 @@ SocketEvent::Dispatch() noexcept
|
|||||||
callback(flags);
|
callback(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
SocketEvent::~SocketEvent() noexcept
|
|
||||||
{
|
|
||||||
if (IsDefined())
|
|
||||||
Cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SocketEvent::Open(SocketDescriptor _fd) noexcept
|
SocketEvent::Open(SocketDescriptor _fd) noexcept
|
||||||
{
|
{
|
||||||
@ -72,11 +66,11 @@ SocketEvent::Close() noexcept
|
|||||||
bool
|
bool
|
||||||
SocketEvent::Schedule(unsigned flags) noexcept
|
SocketEvent::Schedule(unsigned flags) noexcept
|
||||||
{
|
{
|
||||||
assert(IsDefined());
|
|
||||||
|
|
||||||
if (flags == GetScheduledFlags())
|
if (flags == GetScheduledFlags())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
bool success;
|
bool success;
|
||||||
if (scheduled_flags == 0)
|
if (scheduled_flags == 0)
|
||||||
success = loop.AddFD(fd.Get(), flags, *this);
|
success = loop.AddFD(fd.Get(), flags, *this);
|
||||||
|
@ -91,7 +91,9 @@ public:
|
|||||||
callback(_callback),
|
callback(_callback),
|
||||||
fd(_fd) {}
|
fd(_fd) {}
|
||||||
|
|
||||||
~SocketEvent() noexcept;
|
~SocketEvent() noexcept {
|
||||||
|
Cancel();
|
||||||
|
}
|
||||||
|
|
||||||
auto &GetEventLoop() const noexcept {
|
auto &GetEventLoop() const noexcept {
|
||||||
return loop;
|
return loop;
|
||||||
|
@ -52,8 +52,7 @@ DbusToLibevent(unsigned flags) noexcept
|
|||||||
void
|
void
|
||||||
WatchManager::Watch::Toggled() noexcept
|
WatchManager::Watch::Toggled() noexcept
|
||||||
{
|
{
|
||||||
if (event.IsDefined())
|
event.Cancel();
|
||||||
event.Cancel();
|
|
||||||
|
|
||||||
if (dbus_watch_get_enabled(&watch)) {
|
if (dbus_watch_get_enabled(&watch)) {
|
||||||
event.Open(SocketDescriptor(dbus_watch_get_unix_fd(&watch)));
|
event.Open(SocketDescriptor(dbus_watch_get_unix_fd(&watch)));
|
||||||
|
Loading…
Reference in New Issue
Block a user