TitaniumにおけるWindow, Context, Threadについて調べた事を書き出してみました。
大いに間違ってる可能性があるので、ご注意ください。
Window
- Window毎にjavascript contextとthreadを分けられる
- UI処理はmain thread で、その他の処理はwindowまたはapp.jsで処理されている
- Windowが破棄される際に、対象となるWindowで確保されたリソースは破棄される
- app.js上で確保されたリソースはアプリ終了まで解放されないので注意
- Windowを分け、urlプロパティを用いる事で別のJavascriptファイルに処理を分割することができる
ContextとThread
- Titanium は マルチスレッドで動作する
- UIのレンダリングの処理は1つのUIスレッド(又はメインスレッド)が処理する
- Titanium におけるContext は1つのネイティブスレッド(メインUIスレッドではない)を意味する
- UIに関連しない処理は"Context"上で実行される
Reference
As a Titanium developer, I want to understand how threading works in Titanium
https://jira.appcelerator.org/browse/TIDOC-653
Titanium.UI.Window
http://docs.appcelerator.com/titanium/3.0/#!/api/Titanium.UI.Window