Bläddra i källkod

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.
AnotherTest 4 år sedan
förälder
incheckning
bdd4b99d72
2 ändrade filer med 5 tillägg och 0 borttagningar
  1. 2 0
      Libraries/LibIPC/Message.cpp
  2. 3 0
      Libraries/LibIPC/Message.h

+ 2 - 0
Libraries/LibIPC/Message.cpp

@@ -34,6 +34,8 @@ Message::Message()
 
 Message::~Message()
 {
+    if (on_destruction)
+        on_destruction();
 }
 
 }

+ 3 - 0
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();
 };