Skip to content

Commit

Permalink
Fix definition of isfreed()
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWrigley committed Jul 9, 2024
1 parent 1a3d67c commit e5d75e9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/src/_changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/src/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Message(::String)
Message(::SubString{String})
Message(::Array)
Message(::IOBuffer)
isfreed(::Message)
```

## Context
Expand Down
10 changes: 7 additions & 3 deletions src/message.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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) # ?
Expand Down

0 comments on commit e5d75e9

Please sign in to comment.