summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnotherTest <ali.mpfard@gmail.com>2020-12-30 21:02:46 +0330
committerAndreas Kling <kling@serenityos.org>2020-12-30 20:37:41 +0100
commitbdd4b99d725188944b207cee20bef5f557fa7849 (patch)
tree8187bcaced2fab71cdefa851bf24deeaf74f3af4
parentb03e8a6d066c7fb1329099350057ef4606b19d3e (diff)
downloadserenity-bdd4b99d725188944b207cee20bef5f557fa7849.zip
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.
-rw-r--r--Libraries/LibIPC/Message.cpp2
-rw-r--r--Libraries/LibIPC/Message.h3
2 files changed, 5 insertions, 0 deletions
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 <AK/Function.h>
#include <AK/Vector.h>
namespace IPC {
@@ -44,6 +45,8 @@ public:
virtual const char* message_name() const = 0;
virtual MessageBuffer encode() const = 0;
+ Function<void()> on_destruction;
+
protected:
Message();
};