File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,28 @@ for name in names(@__MODULE__; all=true)
4343 @eval export $ name
4444end
4545
46- function init (allocator= aws_default_allocator ())
46+ const DEFAULT_AWS_ALLOCATOR = Ref {Ptr{aws_allocator}} (C_NULL )
47+ const DEFAULT_AWS_ALLOCATOR_LOCK = ReentrantLock ()
48+
49+ function set_default_aws_allocator! (allocator)
50+ @lock DEFAULT_AWS_ALLOCATOR_LOCK begin
51+ DEFAULT_AWS_ALLOCATOR[] = allocator
52+ return
53+ end
54+ end
55+
56+ function default_aws_allocator ()
57+ @lock DEFAULT_AWS_ALLOCATOR_LOCK begin
58+ if DEFAULT_AWS_ALLOCATOR[] == C_NULL
59+ set_default_aws_allocator! (aws_default_allocator ())
60+ end
61+ return DEFAULT_AWS_ALLOCATOR[]
62+ end
63+ end
64+
65+ export default_aws_allocator, set_default_aws_allocator!
66+
67+ function init (allocator= default_aws_allocator ())
4768 aws_common_library_init (allocator)
4869 return
4970end
You can’t perform that action at this time.
0 commit comments