1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Linux: Allow the event bit mask to be specified in LinuxEventLoop::registerFdCallback()

This commit is contained in:
ed 2019-09-06 14:54:36 +01:00
parent 4edb0d2c90
commit 2aed7b58fa
2 changed files with 8 additions and 5 deletions

View file

@ -34,8 +34,11 @@ namespace LinuxEventLoop
@param fd the file descriptor to be monitored
@param readCallback a callback that will be called when the file descriptor has
data to read. The file descriptor will be passed as an argument
@param eventMask a bit mask specifying the events you are interested in for the
file descriptor. The possible values for this are defined in
<poll.h>
*/
void registerFdCallback (int fd, std::function<void(int)> readCallback);
void registerFdCallback (int fd, std::function<void(int)> readCallback, short eventMask = 1 /*POLLIN*/);
/** Unregisters a previously registered file descriptor.

View file

@ -119,12 +119,12 @@ public:
fdReadCallbacks.reserve (8);
}
void registerFdCallback (int fd, std::function<void(int)>&& cb)
void registerFdCallback (int fd, std::function<void(int)>&& cb, short eventMask)
{
const ScopedLock sl (lock);
fdReadCallbacks.push_back ({ fd, std::move (cb) });
pfds.push_back ({ fd, POLLIN, 0 });
pfds.push_back ({ fd, eventMask, 0 });
}
void unregisterFdCallback (int fd)
@ -273,10 +273,10 @@ bool MessageManager::dispatchNextMessageOnSystemQueue (bool returnIfNoPendingMes
}
//==============================================================================
void LinuxEventLoop::registerFdCallback (int fd, std::function<void(int)> readCallback)
void LinuxEventLoop::registerFdCallback (int fd, std::function<void(int)> readCallback, short eventMask)
{
if (auto* runLoop = InternalRunLoop::getInstanceWithoutCreating())
runLoop->registerFdCallback (fd, std::move (readCallback));
runLoop->registerFdCallback (fd, std::move (readCallback), eventMask);
}
void LinuxEventLoop::unregisterFdCallback (int fd)