#ifndef ScopedEventQueue_h
#define ScopedEventQueue_h
+#include <wtf/NeverDestroyed.h>
#include <wtf/Noncopyable.h>
#include <wtf/PassRefPtr.h>
#include <wtf/RefPtr.h>
namespace WebCore {
class Event;
+class EventQueueScope;
class ScopedEventQueue {
WTF_MAKE_NONCOPYABLE(ScopedEventQueue); WTF_MAKE_FAST_ALLOCATED;
public:
- ~ScopedEventQueue();
-
+ static ScopedEventQueue& instance();
void enqueueEvent(PassRefPtr<Event>);
- void dispatchAllEvents();
- static ScopedEventQueue* instance();
-
- void incrementScopingLevel();
- void decrementScopingLevel();
private:
ScopedEventQueue();
- static void initialize();
+ ~ScopedEventQueue();
+
void dispatchEvent(PassRefPtr<Event>) const;
+ void dispatchAllEvents();
+ void incrementScopingLevel();
+ void decrementScopingLevel();
Vector<RefPtr<Event>> m_queuedEvents;
unsigned m_scopingLevel;
- static ScopedEventQueue* s_instance;
+ friend NeverDestroyed<ScopedEventQueue>;
+ friend EventQueueScope;
};
class EventQueueScope {
WTF_MAKE_NONCOPYABLE(EventQueueScope);
-
public:
- EventQueueScope() { ScopedEventQueue::instance()->incrementScopingLevel(); }
- ~EventQueueScope() { ScopedEventQueue::instance()->decrementScopingLevel(); }
+ EventQueueScope() { ScopedEventQueue::instance().incrementScopingLevel(); }
+ ~EventQueueScope() { ScopedEventQueue::instance().decrementScopingLevel(); }
};
}