summaryrefslogtreecommitdiff
path: root/src/event_manager.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2014-11-25 01:00:18 +0000
committerMaxime Coste <frrrwww@gmail.com>2014-11-25 13:52:06 +0000
commit49931fbf056ec1036693c669cec8cde4ea8c95fe (patch)
tree6adb76a625aa106d6d32a3d9796060a9b75312a5 /src/event_manager.hh
parent0272da65c0abf1f7dd3ab214638b6a4d5d390cc4 (diff)
Separate events between normal and urgent ones
Run urgent ones while executing %sh blocks. Fixes #236
Diffstat (limited to 'src/event_manager.hh')
-rw-r--r--src/event_manager.hh25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/event_manager.hh b/src/event_manager.hh
index e14468ba..a88cd620 100644
--- a/src/event_manager.hh
+++ b/src/event_manager.hh
@@ -2,6 +2,7 @@
#define event_manager_hh_INCLUDED
#include "utils.hh"
+#include "flags.hh"
#include <chrono>
#include <unordered_set>
@@ -9,20 +10,28 @@
namespace Kakoune
{
+enum class EventMode
+{
+ Normal = 1 << 0,
+ Urgent = 1 << 1
+};
+
+template<> struct WithBitOps<EventMode> : std::true_type {};
+
class FDWatcher
{
public:
- using Callback = std::function<void (FDWatcher& watcher)>;
+ using Callback = std::function<void (FDWatcher& watcher, EventMode mode)>;
FDWatcher(int fd, Callback callback);
~FDWatcher();
int fd() const { return m_fd; }
- void run() { m_callback(*this); }
+ void run(EventMode mode);
private:
FDWatcher(const FDWatcher&) = delete;
- int m_fd;
- Callback m_callback;
+ int m_fd;
+ Callback m_callback;
};
using Clock = std::chrono::steady_clock;
@@ -33,15 +42,17 @@ class Timer
public:
using Callback = std::function<void (Timer& timer)>;
- Timer(TimePoint date, Callback callback);
+ Timer(TimePoint date, Callback callback,
+ EventMode mode = EventMode::Normal);
~Timer();
TimePoint next_date() const { return m_date; }
void set_next_date(TimePoint date) { m_date = date; }
- void run();
+ void run(EventMode mode);
private:
TimePoint m_date;
+ EventMode m_mode;
Callback m_callback;
};
@@ -56,7 +67,7 @@ public:
EventManager();
~EventManager();
- void handle_next_events();
+ void handle_next_events(EventMode mode);
// force the watchers associated with fd to be executed
// on next handle_next_events call.