Skip to content

Commit 598813d

Browse files
SDKS-3458 - More improvements
1 parent be03b0b commit 598813d

File tree

4 files changed

+46
-56
lines changed

4 files changed

+46
-56
lines changed

PingOrchestrate/PingOrchestrate/HttpClient.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import Foundation
1313
import PingLogger
1414

1515
/// `HttpClient` is responsible for handling HTTP requests and logging the details of those requests and responses.
16-
public final class HttpClient {
17-
var session: URLSession
16+
public final class HttpClient: Sendable {
17+
let session: URLSession
1818

1919
/// Initializes a new instance of `HttpClient`.
2020
/// - Parameter session: The URLSession instance to be used for HTTP requests. Defaults to a session with `RedirectPreventer` delegate.

PingOrchestrate/PingOrchestrate/Node.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public protocol Closeable {
2121
public protocol Node: Sendable {}
2222

2323
/// Represents an EmptyNode node in the workflow.
24-
public struct EmptyNode: Node, @unchecked Sendable {
24+
public struct EmptyNode: Node, Sendable {
2525
public init() {}
2626
}
2727

PingOrchestrate/PingOrchestrate/Request.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Foundation
1313
import UIKit
1414

1515
/// Class for a Request. A Request represents a request to be sent over the network.
16-
public class Request {
16+
public final class Request {
1717

1818
public private(set) var urlRequest: URLRequest = URLRequest(url: URL(string: "https://")!)
1919

PingOrchestrate/PingOrchestrate/SharedContext.swift

+42-52
Original file line numberDiff line numberDiff line change
@@ -13,58 +13,48 @@ import Foundation
1313

1414
/// An actor that manages a shared context using a dictionary.
1515
public final class SharedContext {
16-
private var map: [String: Any] = [:]
17-
private var queue = DispatchQueue(label: "shared.conext.queue", attributes: .concurrent)
16+
private var map: [String: Any]
17+
18+
/// Initializes the SharedContext with an empty dictionary or a pre-existing one.
19+
///
20+
/// - Parameter map: A dictionary to initialize the context with. Defaults to an empty dictionary.
21+
public init(_ map: [String: Any] = [:]) {
22+
self.map = map
23+
}
24+
25+
/// Sets a value for the given key in the shared context.
26+
///
27+
/// - Parameters:
28+
/// - key: The key for which to set the value.
29+
/// - value: The value to set for the given key.
30+
public func set(key: String, value: Any) {
31+
self.map[key] = value
32+
}
33+
34+
/// Retrieves the value for the given key from the shared context.
35+
///
36+
/// - Parameter key: The key for which to get the value.
37+
/// - Returns: The value associated with the key, or `nil` if the key does not exist.
38+
public func get(key: String) -> Any? {
39+
return self.map[key]
1840

19-
/// Initializes the SharedContext with an empty dictionary or a pre-existing one.
20-
///
21-
/// - Parameter map: A dictionary to initialize the context with. Defaults to an empty dictionary.
22-
public init(_ map: [String: Any] = [:]) {
23-
queue.sync(flags: .barrier) {
24-
self.map = map
25-
}
26-
}
41+
}
42+
43+
/// Removes the value for the given key from the shared context.
44+
///
45+
/// - Parameter key: The key for which to remove the value.
46+
/// - Returns: The removed value, or `nil` if the key does not exist.
47+
public func removeValue(forKey key: String) -> Any? {
48+
self.map.removeValue(forKey: key)
49+
}
50+
51+
/// A Boolean value indicating whether the shared context is empty.
52+
public var isEmpty: Bool {
53+
return self.map.isEmpty
54+
}
55+
56+
/// A namespace for key names to be added in an extension.
57+
public enum Keys {
2758

28-
/// Sets a value for the given key in the shared context.
29-
///
30-
/// - Parameters:
31-
/// - key: The key for which to set the value.
32-
/// - value: The value to set for the given key.
33-
public func set(key: String, value: Any) {
34-
queue.sync(flags: .barrier) {
35-
self.map[key] = value
36-
}
37-
}
38-
39-
/// Retrieves the value for the given key from the shared context.
40-
///
41-
/// - Parameter key: The key for which to get the value.
42-
/// - Returns: The value associated with the key, or `nil` if the key does not exist.
43-
public func get(key: String) -> Any? {
44-
queue.sync {
45-
return self.map[key]
46-
}
47-
}
48-
49-
/// Removes the value for the given key from the shared context.
50-
///
51-
/// - Parameter key: The key for which to remove the value.
52-
/// - Returns: The removed value, or `nil` if the key does not exist.
53-
public func removeValue(forKey key: String) -> Any? {
54-
queue.sync(flags: .barrier) {
55-
self.map.removeValue(forKey: key)
56-
}
57-
}
58-
59-
/// A Boolean value indicating whether the shared context is empty.
60-
public var isEmpty: Bool {
61-
queue.sync {
62-
return self.map.isEmpty
63-
}
64-
}
65-
66-
/// A namespace for key names to be added in an extension.
67-
public enum Keys {
68-
69-
}
59+
}
7060
}

0 commit comments

Comments
 (0)