Commit 5ffe3773 authored by Max Kellermann's avatar Max Kellermann

event/MaskMonitor: add variant with bound method

parent a7c68018
......@@ -22,6 +22,7 @@
#include "check.h"
#include "DeferredMonitor.hxx"
#include "util/BoundMethod.hxx"
#include <atomic>
......@@ -50,4 +51,22 @@ protected:
void RunDeferred() override;
};
/**
* A variant of #MaskMonitor which invokes a bound method.
*/
template<typename T>
class CallbackMaskMonitor final : public MaskMonitor {
BoundMethod<T, void, unsigned> callback;
public:
template<typename... Args>
explicit CallbackMaskMonitor(EventLoop &_loop, Args&&... args)
:MaskMonitor(_loop), callback(std::forward<Args>(args)...) {}
protected:
void HandleMask(unsigned mask) override {
callback(mask);
}
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment