현재 Swift 3.0에서 일하고 있습니다. Dispatch_Queue에 배치 된 함수에서 호출 된 함수가 동일한 Dispatch_Queue에도 배치되는지 또는 Main에 다시 배치되는지 궁금합니다.dispatch_queue의 부모 함수에서 호출 된 함수가 main 또는 dispatch_queue에 배치됩니까?
아래 예제 스 니펫이 포함되어 있습니다.이 경우 parentFunction1()이 MyQueue에 배치되었거나 calledFromParentFunction()이 Main에서 호출 되었기 때문에 calledFromParentFunction()이 MyQueue에서 호출되었는지 궁금합니다. MyQueue를 명시 적으로 호출하지 않았습니까?
let MyQueue = DispatchQueue(label: "My Queue", attributes: [], target: nil)
parentFunction1() {
calledFromParentFunction()
}
calledFromParentFunction() {
print("Is this on Main or MyQueue?")
}
override func viewDidLoad() {
super.viewDidLoad()
MyQueue.async { [unowned self] in
parentFunction1()
}
}
는'Thread' 클래스 var에 isMainThread'로 설명하는 방법이있다. –
달리 수행 할 특정 코드가 없으면 전체 호출 스택이 동일한 큐에 있습니다. – rmaddy
알았어요, 고마워요! – TheMuffinMan834