Skip to content

Commit

Permalink
fix: websocket deadlock for high amounts of concurrency (#141)
Browse files Browse the repository at this point in the history
* fix: send websocket request only when promise was set

* fix: only decode once for path decision

* fix: concurrency issue with websocket send

* fix: websocket wait for response before continuing

* fix: async exec receive ws messages

* fix: increase max frame size

* fix: single threaded ws group

* fix: sometimes websocket was not initialized

* fix: revert to 4 threads

* fix: avoid deadlock by having multiple seperate queues

* fix: switch from semaphores to closures

* fix: do not send from queue

* fix: do not access synchronized array synchronously
  • Loading branch information
koraykoska authored Nov 1, 2022
1 parent eff1a97 commit c076d6a
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 133 deletions.
6 changes: 6 additions & 0 deletions Sources/Core/Toolbox/SynchronizedDictionary.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public final class SynchronizedDictionary<KeyType: Hashable, ValueType>: Sequenc
}
}

public func getValueAsync(key: KeyType, response: @escaping (_ value: ValueType?) -> Void) {
accessQueue.async {
response(self.internalDictionary[key])
}
}

private func setValue(value: ValueType?, forKey key: KeyType) {
accessQueue.async(flags: .barrier) {
self.internalDictionary[key] = value
Expand Down
Loading

0 comments on commit c076d6a

Please sign in to comment.