Skip to content

Commit

Permalink
fix: semaphore signal 누락된 부분 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeffie committed Feb 13, 2024
1 parent 2a65193 commit 0e24dbe
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions BankManagerUIApp/BankManagerUIApp/ViewModel/BankViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ extension BankViewModel: BankManagerDelegate {
self.waitingSemaphore.wait()
guard
let index = self.waitingList.firstIndex(where: { target in client == target })
else { return }
else {
self.waitingSemaphore.signal()
return
}
self.waitingList.remove(at: index)
self.waitingSemaphore.signal()
}
Expand All @@ -76,7 +79,7 @@ extension BankViewModel: BankManagerDelegate {
DispatchQueue.global().async {
self.waitingSemaphore.wait()
self.waitingList.append(client)
self.waitingSemaphore.signal()
self.waitingSemaphore.signal()
}
}

Expand All @@ -85,7 +88,10 @@ extension BankViewModel: BankManagerDelegate {
self.workingSemaphore.wait()
guard
let index = self.workingList.firstIndex(where: { target in client == target })
else { return }
else {
self.workingSemaphore.signal()
return
}
self.workingList.remove(at: index)
self.workingSemaphore.signal()
}
Expand All @@ -102,9 +108,11 @@ extension BankViewModel: BankManagerDelegate {
func handleClearClient() {
DispatchQueue.global().async {
self.waitingSemaphore.wait()
self.workingSemaphore.wait()
self.waitingList.removeAll()
self.workingList.removeAll()
self.waitingSemaphore.signal()
self.workingSemaphore.signal()
}
}

Expand Down

0 comments on commit 0e24dbe

Please sign in to comment.