Command Line Toolでデバッグするとスレッドが1つのまま動いているように見えました。
*iOSでデバッグするとスレッドは2つ3つありました
次の引用に関係しているかもしれません。
Default dispatch queueの指定をしてあげると、動きはまだ微妙かもしれませんが、スレッドが2つになって、work2も呼び出されているように見えました。
Promises use GCD internally and make all APIs provide a way to specify which dispatch queue each block of work should be dispatched on. Main queue is the default, if one isn't specified. Setting the default dispatch queue to any other than the main is normally needed when the main one is busy serving some custom event run loop, but not the standard for Apple platforms CFRunLoop. That situation is pretty common for different server-side frameworks, that similarly to AppKit/UIKit, also implement the inversion of control design principle and park the main thread in a custom run loop. To specify the default dispatch queue, add the following line to the beginning of your program:
(機械翻訳)Promises は内部的に GCD を使用し,すべての API で各ブロックがどのディスパッチキューにディスパッチされるべきかを指定する方法を提供するようにしています.メインキューは、指定されなければデフォルトです。デフォルトのディスパッチキューをメイン以外のキューに設定することは、通常、メインが何らかのカスタムイベント実行ループの提供に忙しいときに必要になりますが、Apple プラットフォームの標準である CFRunLoop ではありません。このような状況は、AppKit/UIKit と同様に、制御の逆転の設計原理を実装し、カスタム実行ループでメインスレッドをパークする、別のサーバーサイドフレームワークではかなり一般的です。デフォルトのディスパッチキューを指定するには、プログラムの最初に次の行を追加します。
swift
1DispatchQueue.promises = .global()
https://github.com/google/promises/blob/master/g3doc/index.md#default-dispatch-queue
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/07/16 07:17