-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
은행창구 매니저 [Step3] 토이, 쥬봉이 #330
base: ic_10_toy123
Are you sure you want to change the base?
Conversation
- String 원시값 설정 - CaseIterable 프로토콜 채택
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨어요.
비동기 처리가 많이 어려우셨을텐데, 잘 해주셨어요.
OperationQueue로도 잘 구현을 해주셨네요.
스텝이 작기도하고, 충분히 고민을 많이 해주신 것 같아서 코멘트는 없습니다.
다만 질문이 하나 있어요.
Q: 혹시 언제 OperationQueue를 사용해야만 할까요? DispatchQueue보다 OperationQueue가 더 제공하는 점은 어떤게 있을까요?
public func assignCustomer(to bankClerk: [Banking: BankClerk]) { | ||
let group = DispatchGroup() | ||
let semaphore = DispatchSemaphore(value: 2) | ||
let depositQueue = DispatchQueue(label: "depositQueue", attributes: .concurrent) | ||
let loanQeueue = DispatchQueue(label: "loanQueue") | ||
|
||
while let customer = customerQueue.dequeue() as? BankClerk.Customer, | ||
let banking = customer.banking { | ||
switch banking { | ||
case .deposit: | ||
depositQueue.async(group: group) { | ||
semaphore.wait() | ||
bankClerk[banking]?.receive(customer: customer) | ||
semaphore.signal() | ||
} | ||
case .loan: | ||
loanQeueue.async(group: group) { | ||
bankClerk[banking]?.receive(customer: customer) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public enum Banking: String, CaseIterable { | ||
case deposit = "예금" | ||
case loan = "대출" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CustomStringConvertible
이라는 프로토콜을 사용해도 좋을 것 같아요.
@@ -1,3 +1,4 @@ | |||
public protocol CustomerNumbering { | |||
var number: UInt { get } | |||
var banking: Banking? { get } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
굳이 옵셔널일 필요가 있을까요? randomElement()
가 옵셔널을 반환한다면, 기본값을 지정해줘도 좋을 것 같아요.
private let work: Banking | ||
private var pace: Double { | ||
switch work { | ||
case .deposit: | ||
return 0.7 | ||
case .loan: | ||
return 1.1 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 이 정보가 은행원보다는 업무
에 들어가야한다고 생각해요. 현재 은행원에 따라 속도차이가 나는게 아니라, 업무에 따라 속도 차이가 나기 때문이에요.
@1Consumption
올라프 늦었지만 Step3 PR 보냅니다💪
비동기처리를 하는 부분이 어려웠습니다.
GCD, Operation 등 열심히 공부해보았고 지금도 하고 있습니다!
이번 스텝도 잘부탁드립니다.
구현 화면
고민이 되었던 점
serial queue
로 구현하여차례로
대출업무가 수행되도록 구현하였습니다.group
으로 묶어주어 이 group이 끝날때까지 현재 스레드가 기다리도록group.wait()
을 사용하였습니다.조언을 구하고 싶은 부분