mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:47:46 +00:00
LibIPC: Use a zero-delay timer for message processing
This lets us avoid using Core::deferred_invoke() which is not usable during application teardown (as there is no event loop to push the deferred invocation onto.) (Not that there is an event loop to fire the processing timer during teardown *either*, but at least we can exit gracefully with pending timers, unlike deferred invocations, which hang the process. This is an area where more improvements are definitely needed!)
This commit is contained in:
parent
24642861af
commit
3bed7d5a5e
2 changed files with 4 additions and 3 deletions
|
@ -17,6 +17,7 @@ ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullRefPtr<Core::LocalS
|
|||
, m_local_endpoint_magic(local_endpoint_magic)
|
||||
{
|
||||
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
|
||||
m_processing_timer = Core::Timer::create_single_shot(0, [this] { handle_messages(); });
|
||||
}
|
||||
|
||||
ConnectionBase::~ConnectionBase()
|
||||
|
@ -175,9 +176,8 @@ bool ConnectionBase::drain_messages_from_peer()
|
|||
}
|
||||
|
||||
if (!m_unprocessed_messages.is_empty()) {
|
||||
deferred_invoke([this] {
|
||||
handle_messages();
|
||||
});
|
||||
if (!m_processing_timer->is_active())
|
||||
m_processing_timer->start();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ protected:
|
|||
|
||||
NonnullRefPtr<Core::LocalSocket> m_socket;
|
||||
RefPtr<Core::Timer> m_responsiveness_timer;
|
||||
RefPtr<Core::Timer> m_processing_timer;
|
||||
|
||||
RefPtr<Core::Notifier> m_notifier;
|
||||
NonnullOwnPtrVector<Message> m_unprocessed_messages;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue