Skip to content

Commit

Permalink
more work
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnj committed Jun 11, 2024
1 parent 9282c20 commit 08fafe1
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/LibAwsCommon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,22 @@ for name in names(@__MODULE__; all=true)
end

const DEFAULT_AWS_ALLOCATOR = Ref{Ptr{aws_allocator}}(C_NULL)
const DEFAULT_AWS_ALLOCATOR_LOCK = ReentrantLock()

function default_aws_allocator()
if DEFAULT_AWS_ALLOCATOR[] == C_NULL
DEFAULT_AWS_ALLOCATOR[] = aws_default_allocator()
function set_default_aws_allocator!(allocator)
@lock DEFAULT_AWS_ALLOCATOR_LOCK begin
DEFAULT_AWS_ALLOCATOR[] = allocator
return
end
return DEFAULT_AWS_ALLOCATOR[]
end

function set_default_aws_allocator!(allocator)
DEFAULT_AWS_ALLOCATOR[] = allocator
return
function default_aws_allocator()
@lock DEFAULT_AWS_ALLOCATOR_LOCK begin
if DEFAULT_AWS_ALLOCATOR[] == C_NULL
set_default_aws_allocator!(aws_default_allocator())
end
return DEFAULT_AWS_ALLOCATOR[]
end
end

export default_aws_allocator, set_default_aws_allocator!
Expand Down

0 comments on commit 08fafe1

Please sign in to comment.