From bdd4b99d725188944b207cee20bef5f557fa7849 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Wed, 30 Dec 2020 21:02:46 +0330 Subject: LibIPC: Add an on_destruction hook to IPC::Message Any cleanup of resources needed (up until the message is sent) can be done here. Currently, the only such resource is an IPC::File. --- Libraries/LibIPC/Message.cpp | 2 ++ Libraries/LibIPC/Message.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Libraries/LibIPC/Message.cpp b/Libraries/LibIPC/Message.cpp index 10919b70de..7d3e40dcf6 100644 --- a/Libraries/LibIPC/Message.cpp +++ b/Libraries/LibIPC/Message.cpp @@ -34,6 +34,8 @@ Message::Message() Message::~Message() { + if (on_destruction) + on_destruction(); } } diff --git a/Libraries/LibIPC/Message.h b/Libraries/LibIPC/Message.h index 495e751adc..90dc57bb5e 100644 --- a/Libraries/LibIPC/Message.h +++ b/Libraries/LibIPC/Message.h @@ -26,6 +26,7 @@ #pragma once +#include #include namespace IPC { @@ -44,6 +45,8 @@ public: virtual const char* message_name() const = 0; virtual MessageBuffer encode() const = 0; + Function on_destruction; + protected: Message(); }; -- cgit v1.2.3