mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:47:35 +00:00
LibCore: Remove main event loop
The main event loop functionality was used in just two places where the alternative is a bit simpler. Remove it in favor of referencing the event loop directly, or just invoking `EventLoop::current()`. Note that we don't need locking in the constructor since we're now only modifying a thread-local `Vector`. We also don't need locking in the old call sites to `::with_main_locked()` since we already lock the event loop in the subsequent `::post_event()` invocation.
This commit is contained in:
parent
9e2a619fdc
commit
f25123df66
4 changed files with 21 additions and 46 deletions
|
@ -26,8 +26,6 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
extern Threading::MutexProtected<EventLoop*> s_main_event_loop;
|
||||
|
||||
class EventLoop {
|
||||
public:
|
||||
enum class MakeInspectable {
|
||||
|
@ -59,14 +57,6 @@ public:
|
|||
|
||||
void post_event(Object& receiver, NonnullOwnPtr<Event>&&, ShouldWake = ShouldWake::No);
|
||||
|
||||
template<typename Callback>
|
||||
static decltype(auto) with_main_locked(Callback callback)
|
||||
{
|
||||
return s_main_event_loop.with_locked([&callback](auto*& event_loop) {
|
||||
VERIFY(event_loop != nullptr);
|
||||
return callback(event_loop);
|
||||
});
|
||||
}
|
||||
static EventLoop& current();
|
||||
|
||||
bool was_exit_requested() const { return m_exit_requested; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue