Remove reference to method that isn't in panama anymore
This commit is contained in:
parent
daa1949f32
commit
9d65f47a96
2 changed files with 13 additions and 8 deletions
|
|
@ -5,6 +5,9 @@ All notable changes to this project will be documented in this file. This change
|
||||||
### Added
|
### Added
|
||||||
- An `::ffi/address` key to wrapper functions' metadata
|
- An `::ffi/address` key to wrapper functions' metadata
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Usage of a method no longer in Panama that breaks `with-acquired`
|
||||||
|
|
||||||
## [0.1.184] - 2021-09-30
|
## [0.1.184] - 2021-09-30
|
||||||
### Fixed
|
### Fixed
|
||||||
- Deserializing nullpointers as functions threw an exception
|
- Deserializing nullpointers as functions threw an exception
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
MemoryLayout
|
MemoryLayout
|
||||||
MemorySegment
|
MemorySegment
|
||||||
ResourceScope
|
ResourceScope
|
||||||
|
ResourceScope$Handle
|
||||||
SegmentAllocator)))
|
SegmentAllocator)))
|
||||||
|
|
||||||
(defn stack-scope
|
(defn stack-scope
|
||||||
|
|
@ -96,11 +97,6 @@
|
||||||
([allocator size alignment]
|
([allocator size alignment]
|
||||||
(.allocate ^SegmentAllocator allocator (long size) (long alignment))))
|
(.allocate ^SegmentAllocator allocator (long size) (long alignment))))
|
||||||
|
|
||||||
(defn keep-alive
|
|
||||||
"Ensures that the scope `target` is not released before `source`."
|
|
||||||
[source target]
|
|
||||||
(.keepAlive ^ResourceScope source ^ResourceScope target))
|
|
||||||
|
|
||||||
(defmacro with-acquired
|
(defmacro with-acquired
|
||||||
"Acquires one or more `scopes` until the `body` completes.
|
"Acquires one or more `scopes` until the `body` completes.
|
||||||
|
|
||||||
|
|
@ -109,9 +105,15 @@
|
||||||
with it wrapped in this."
|
with it wrapped in this."
|
||||||
{:style/indent 1}
|
{:style/indent 1}
|
||||||
[scopes & body]
|
[scopes & body]
|
||||||
`(with-open [scope# (stack-scope)]
|
`(let [scopes# (vec ~scopes)
|
||||||
(run! (partial keep-alive scope#) ~scopes)
|
handles# (mapv #(.acquire ^ResourceScope %) scopes#)]
|
||||||
~@body))
|
(try ~@body
|
||||||
|
(finally
|
||||||
|
(doseq [idx# (range (count scopes#))
|
||||||
|
:let [scope# (nth scopes# idx#)
|
||||||
|
handle# (nth handles# idx#)]]
|
||||||
|
(.release ^ResourceScope scope#
|
||||||
|
^ResourceScope$Handle handle#))))))
|
||||||
(s/fdef with-acquired
|
(s/fdef with-acquired
|
||||||
:args (s/cat :scopes any?
|
:args (s/cat :scopes any?
|
||||||
:body (s/* any?)))
|
:body (s/* any?)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue