I am wondering about the following scenario.
I have a DispatchGroup
inside a function. Now I am entering the group on a background thread and calling wait()
.
func test() {
let group = DispatchGroup()
DispatchQueue.global().async {
group.enter()
group.wait()
}
}
My question is whether the group will wait forever or get deallocated after the main thread leaves the function?
I am not sure if there is any referencing or capturing. I would be very thankful for some explanation, this topic confuses me a bit.
Thank you in advance!