問題タブ [runloop]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
multithreading - osx と ios のメイン スレッドでループを実行する
本当に基本的なことを行うための参照が見つかりません。メインの UI ループで「forever」というメソッドが必要です。UI のリフレッシュ レートと同期してメソッドを呼び出す方法と、50 ~ 100 ミリ秒ごとに頻繁に実行する必要がないため、カスタムの時間粒度を渡す方法の両方に満足しています。C++ (Carbon) と Objective C の両方の答えは問題ありませんが、最終的には純粋な C++ アプリケーションで使用します。このタイマーを削除する方法も提案できれば、それは素晴らしいことです。
これを使用したいスレッド化シナリオの詳細については、コメントを確認してください。
何かのようなもの
ios - Is it possible to check that main thread is idle / to drain a main run loop?
I've just read the following post and have tried to implement the approach described there:
Writing iOS acceptance tests using Kiwi - Being Agile
All the stuff described there does work perfectly. But! there is one thing that breaks determinism when I am running my acceptance tests.
Here is the repo on Github where author of the post pushed his experiments (it can be found on the bottom of the page in the comments): https://github.com/moredip/2012-Olympics-iOS--iPad-and-iPhone--source-code/tree/kiwi-acceptance-mk1
Consider this code he uses for tapping a view:
...where sleepFor
has the following definition behind itself:
It is a naive attempt ('naive' is not about the author, but about the fact that it is the first thing that comes into a head) to wait for a tiny period of time until all the animations are processed and soak all the possible events that were(or could be) scheduled to a main run loop (see also this comment).
The problem is that this naive code does not work in a deterministic way. There are a bunches of UI interactions which cause fx next button tap to be pressed before the current edited textfield's keyboard is disappeared and so on...
If I just increase the time from 0.1 to fx 1 all the problems disappear, but this leads to that every single interaction like "fill in textfield with a text..." or "tap button with title..." become to cost One second!
So I don't mean just increasing a wait time here, but rather a way to make such artificial waits guarantee that I do can proceed my test case with a next step.
I hope that it should be a more reliable way to wait enough until all the stuff caused by current action (all the transitions/animations or whatever main run loop stuff) are done.
To summarize it all to be a question:
Is there a way to exhaust/drain/soak all the stuff scheduled to a main thread and its run loop to be sure that main thread is idle and its run loop is "empty"?
This was my initial solution:
iphone - performSelector:onThread が実行ループを壊しますか?
API の使用方法がわからないため、performSelector:onThread
ここでいくつかの提案が必要です。
私の知る限り、 をrunloop
呼び出すには が必要なので、作成しperformSelector:onThread
ました。しかし、その後、問題が見つかりました。一度電話するとperformSelector:onThread
、runloop
停止します。
これが私のテストコードです。runloop は にありfunction kickOffThread
ます。
kickOffThread
私は次のように呼びますperformInBackground
:
mainThread で、次の API を呼び出して threadCheck を YES に設定します。正しく呼び出されますが、スレッド ループが突然停止します。
端末ログの結果は次のとおりです。「thread exit ....」は出力されません。誰が私に問題がどこにあるのか教えてくれますか?
ios - スレッド内の NSRunloop
問題が発生しました
ここにコードがあります
私が電話するとき
スレッドは実行され続け、後でスレッドで何かを行うことができます。
しかし、私がそれを呼び出さないと、スレッドはすぐに終了し、スレッドを使用して何もできないのはなぜですか?
ios - ゲーム ループの更新メソッドで使用されるタイム デルタまたはタイムスタンプは何ですか?
たとえば、cocos2D では次のようになります。
誰かがこれらのタイム デルタまたはタイムスタンプが何のために使用されているかを説明できますか? ゲームの世界が更新される方法とどのように関連していますか? fps が確実にわからないため、 -update 呼び出しに基づくインクリメンタル プロパティ更新だけに頼るべきではないのでしょうか?
macos - 「実行ループにジャンプ」できますか?
私は、xCode を使用した最初の主要な OSX アプリケーションの生産段階に入りました。これは、さまざまな API 呼び出しを開始する多数のボタンを使用して eBay にアクセスし、結果を解析して表示する e コマース アプリです。かなり大きくなり、私の最初の xCode アプリで想像できるように、コード構造は最適ではありません。しかし、それは現在生産中であり、私は大規模なリストラの危険を冒したくありません.
私の質問は次のとおりです。コードにはいくつかのポイントがあり、多数のメソッド呼び出しが深く、実行ループに戻ってボタンが押されるのを待ちたいところです。そこに到達するために必要なすべてのリターンを行うことは、現時点では実用的ではありません。
実行ループを「GOTO」する方法はありますか?
ありがとう!
python - 実行ループの実装
MIDI キーボードのキーを押したときにアクションを実行する Python スクリプトを作成しています。
では、ホイールを回転させて不要な CPU を消耗させずに、スクリプトがコールバックを応答的に処理できるようにするにはどうすればよいでしょうか?
初期の Visual Studio 時代から、'while( true ) { doevents(); ' を覚えています。}' タイプ コンストラクト -- オペレーティング システムはアクティブなプロセスを循環し、それぞれに特定のタイム スライスを割り当てます。このコマンドは単に制御をスケジューラに返します。
しかし、私は OSX を使用しており、プラットフォームに依存しない Python スクリプトを作成したいと考えています。
できますか?
ios - POSIXファイル記述子をiOSランループに追加して、いつデータを読み取ることができるかを示す方法は?
iOS プログラムにパイプがあり、読み取るデータがあるときにメインの実行ループ (または他の実行ループ) に通知してもらいたい...
では、パイプのファイル記述子をランループに追加するにはどうすればよいでしょうか?
(内部では、アプリがイベントを受け取るために select/kqueue/poll/whatever を実行している必要があると確信しているため、その呼び出しに FD を取得するだけで問題になるはずですが、関連する情報が見つかりません適切な API 呼び出しとは何か)。