DispatchQueue
の多重度を調べてみたところ、64個であることがわかった。
【2018/08/31 0:00 訂正】以前50と書いていたが、数え間違えていた…(´・ω・`)
確認コード
let semaphore = DispatchSemaphore(value: 0) for id in 1..<100 { DispatchQueue.global(qos: .default).async { Thread.sleep(forTimeInterval: 0.5) NSLog("id: \(id)") guard id == 99 { return } semaphore.signal() } } semaphore.wait()
結果
2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642945] id: 46 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642912] id: 13 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642920] id: 21 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642935] id: 36 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642943] id: 44 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642915] id: 16 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642906] id: 7 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642950] id: 51 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642952] id: 53 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642937] id: 38 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642938] id: 39 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642911] id: 12 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642913] id: 14 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642903] id: 4 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642900] id: 1 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642948] id: 49 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642933] id: 34 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642921] id: 22 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642918] id: 19 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642909] id: 10 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642901] id: 2 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642939] id: 40 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642910] id: 11 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642907] id: 8 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642941] id: 42 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642955] id: 56 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642908] id: 9 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642954] id: 55 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642947] id: 48 2018-08-29 23:09:36.512 HTTP-CLIENT[79197:7642924] id: 25 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642961] id: 62 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642917] id: 18 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642926] id: 27 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642922] id: 23 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642957] id: 58 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642932] id: 33 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642960] id: 61 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642931] id: 32 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642925] id: 26 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642928] id: 29 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642944] id: 45 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642927] id: 28 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642936] id: 37 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642959] id: 60 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642905] id: 6 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642958] id: 59 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642916] id: 17 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642949] id: 50 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642934] id: 35 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642963] id: 64 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642951] id: 52 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642956] id: 57 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642942] id: 43 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642914] id: 15 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642946] id: 47 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642962] id: 63 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642902] id: 3 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642940] id: 41 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642953] id: 54 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642919] id: 20 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642923] id: 24 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642904] id: 5 2018-08-29 23:09:36.513 HTTP-CLIENT[79197:7642929] id: 30 2018-08-29 23:09:36.514 HTTP-CLIENT[79197:7642930] id: 31 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642943] id: 69 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642945] id: 65 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642915] id: 70 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642935] id: 68 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642912] id: 66 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642920] id: 67 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642906] id: 71 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642950] id: 72 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642952] id: 73 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642937] id: 74 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642911] id: 76 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642948] id: 80 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642913] id: 77 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642903] id: 78 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642909] id: 84 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642900] id: 79 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642938] id: 75 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642918] id: 83 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642901] id: 85 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642921] id: 82 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642933] id: 81 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642939] id: 86 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642910] id: 87 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642941] id: 89 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642907] id: 88 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642955] id: 90 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642908] id: 91 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642954] id: 92 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642961] id: 95 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642924] id: 94 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642947] id: 93 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642926] id: 97 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642917] id: 96 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642922] id: 98 2018-08-29 23:09:37.017 HTTP-CLIENT[79197:7642957] id: 99