Mirror von
https://github.com/tkuschel/bees.git
synchronisiert 2026-06-19 06:57:54 +02:00
crucible: add cleanup class
Store a function (or closure) in an instance and invoke the function from the destructor. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
Dieser Commit ist enthalten in:
+2
-1
@@ -3,8 +3,9 @@ TAG := $(shell git describe --always --dirty || echo UNKNOWN)
|
||||
default: libcrucible.so
|
||||
|
||||
OBJS = \
|
||||
crc64.o \
|
||||
chatter.o \
|
||||
cleanup.o \
|
||||
crc64.o \
|
||||
error.o \
|
||||
extentwalker.o \
|
||||
fd.o \
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include <crucible/cleanup.h>
|
||||
|
||||
namespace crucible {
|
||||
|
||||
Cleanup::Cleanup(function<void()> func) :
|
||||
m_cleaner(func)
|
||||
{
|
||||
}
|
||||
|
||||
Cleanup::~Cleanup()
|
||||
{
|
||||
if (m_cleaner) {
|
||||
m_cleaner();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren