From 75910f0ab3240a065803abfc5be99d26fb080621 Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Thu, 16 Sep 2021 16:54:13 -0500 Subject: [PATCH] Add a global resource scope --- src/coffi/ffi.clj | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/coffi/ffi.clj b/src/coffi/ffi.clj index 86308aa..2a9bac1 100644 --- a/src/coffi/ffi.clj +++ b/src/coffi/ffi.clj @@ -50,6 +50,16 @@ ^ResourceScope [] (ResourceScope/newImplicitScope)) +(defn global-scope + "Constructs the global scope, which will never reclaim its resources. + + This scope may be shared across threads, but is intended mainly in cases where + memory is allocated with [[alloc]] but is either never freed or whose + management is relinquished to a native library, such as when returned from a + callback." + ^ResourceScope [] + (ResourceScope/globalScope)) + (defn alloc "Allocates `size` bytes.