From 65c7544cc7ed9d6c815da821a9a9899cf185b3e4 Mon Sep 17 00:00:00 2001 From: Joshua Suskalo Date: Wed, 16 Nov 2022 16:58:20 -0600 Subject: [PATCH] Add extra constructors for sessions --- src/clj/coffi/mem.clj | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/clj/coffi/mem.clj b/src/clj/coffi/mem.clj index b9880fe..dd3372a 100644 --- a/src/clj/coffi/mem.clj +++ b/src/clj/coffi/mem.clj @@ -38,6 +38,7 @@ ValueLayout$OfFloat ValueLayout$OfDouble ValueLayout$OfAddress) + (java.lang.ref Cleaner) (java.nio ByteOrder))) (set! *warn-on-reflection* true) @@ -47,8 +48,10 @@ The memory allocated within this session is cheap to allocate, like a native stack." - ^MemorySession [] - (MemorySession/openConfined)) + (^MemorySession [] + (MemorySession/openConfined)) + (^MemorySession [^Cleaner cleaner] + (MemorySession/openConfined cleaner))) (defn ^:deprecated stack-scope "Constructs a new scope for use only in this thread. @@ -63,8 +66,10 @@ This session can be shared across threads and memory allocated in it will only be cleaned up once every thread accessing the session closes it." - ^MemorySession [] - (MemorySession/openShared)) + (^MemorySession [] + (MemorySession/openShared)) + (^MemorySession [^Cleaner cleaner] + (MemorySession/openShared cleaner))) (defn ^:deprecated shared-scope "Constructs a new shared scope.