Skip to content

Commit 9325dbb

Browse files
Merge pull request #188 from mixpanel/jared-sync-props-writes
use semaphore to prevent concurrent access to properties object
2 parents 5cec1b2 + 522feaf commit 9325dbb

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ios/AutomaticProperties.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ import Mixpanel
33

44
class AutomaticProperties {
55
static var peopleProperties: Dictionary<String, MixpanelType> = [:];
6+
private static let semaphore = DispatchSemaphore(value: 0)
7+
68

79
static func setAutomaticProperties(_ properties: [String: Any]) {
8-
for (key,value) in properties ?? [:] {
10+
semaphore.wait()
11+
for (key,value) in properties {
912
peopleProperties[key] = MixpanelTypeHandler.mixpanelTypeValue(value)
1013
}
14+
semaphore.signal()
1115
}
1216
}

0 commit comments

Comments
 (0)