Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into jbe/better_bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins committed Nov 13, 2024
2 parents 6647acc + 0d179b2 commit 0158188
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Smithy/Context.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import class Foundation.NSRecursiveLock

public class Context {
private var _attributes: Attributes
private var lock = NSRecursiveLock()
private let lock = NSRecursiveLock()

public init(attributes: Attributes) {
self._attributes = attributes
Expand All @@ -23,7 +23,8 @@ public class Context {
return accessAttributes().get(key: AttributeKeys.logger)
}

@discardableResult private func accessAttributes(accessor: ((inout Attributes) -> Void)? = nil) -> Attributes {
@discardableResult
private func accessAttributes(accessor: ((inout Attributes) -> Void)? = nil) -> Attributes {
lock.lock()
defer { lock.unlock() }
accessor?(&_attributes)
Expand All @@ -32,6 +33,7 @@ public class Context {
}

extension Context {

public func get<T>(key: AttributeKey<T>) -> T? {
accessAttributes().get(key: key)
}
Expand Down

0 comments on commit 0158188

Please sign in to comment.