From e5d75e933e59469390450b6b27734e1ef7f363ad Mon Sep 17 00:00:00 2001 From: JamesWrigley Date: Tue, 9 Jul 2024 17:08:38 +0200 Subject: [PATCH] Fix definition of isfreed() --- docs/src/_changelog.md | 4 ++++ docs/src/reference.md | 1 + src/message.jl | 10 +++++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/src/_changelog.md b/docs/src/_changelog.md index d125358..2bc9f9d 100644 --- a/docs/src/_changelog.md +++ b/docs/src/_changelog.md @@ -13,6 +13,10 @@ Changelog](https://keepachangelog.com). - Support for creating [`Message`](@ref)'s from the new `Memory` type in Julia 1.11 ([#244]). +### Fixed +- Fixed [`isfreed()`](@ref), which would previously return the wrong values + ([#245]). + ## [v1.2.6] - 2024-06-13 ### Added diff --git a/docs/src/reference.md b/docs/src/reference.md index daf8aac..099c22a 100644 --- a/docs/src/reference.md +++ b/docs/src/reference.md @@ -60,6 +60,7 @@ Message(::String) Message(::SubString{String}) Message(::Array) Message(::IOBuffer) +isfreed(::Message) ``` ## Context diff --git a/src/message.jl b/src/message.jl index f1849c0..4d8d05a 100644 --- a/src/message.jl +++ b/src/message.jl @@ -129,9 +129,13 @@ mutable struct Message <: AbstractArray{UInt8,1} end end -# check whether zeromq has called our free-function, i.e. whether -# we are save to reclaim ownership of any buffer object -isfreed(m::Message) = haskey(gc_protect, getfield(m, :handle)) +""" + isfreed(m::Message) + +Check whether zeromq has called our free-function, i.e. whether we are safe to +reclaim ownership of any buffer object the [`Message`](@ref) was created with. +""" +isfreed(m::Message) = !haskey(gc_protect, getfield(m, :handle)) # AbstractArray behaviors: Base.similar(a::Message, ::Type{T}, dims::Dims) where {T} = Array{T}(undef, dims) # ?