Browse Source

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

tags/2021-05-28
ed 6 years ago
parent
commit
2aed7b58fa
2 changed files with 8 additions and 5 deletions
  1. +4
    -1
      modules/juce_events/native/juce_linux_EventLoop.h
  2. +4
    -4
      modules/juce_events/native/juce_linux_Messaging.cpp

+ 4
- 1
modules/juce_events/native/juce_linux_EventLoop.h 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.


+ 4
- 4
modules/juce_events/native/juce_linux_Messaging.cpp 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)


Loading…
Cancel
Save