チェンジセット 653
- コミット日時:
- 2008/06/19 17:12:46 (5 ヶ月前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/Thread/trunk/Thread.as3proj
r641 r653 69 69 <!-- Class files to compile (other referenced classes will automatically be included) --> 70 70 <compileTargets> 71 <compile path="samples\ progress\Sample.as" />71 <compile path="samples\urlloader\Sample.as" /> 72 72 </compileTargets> 73 73 <!-- Paths to exclude from the Project Explorer tree --> as3/Thread/trunk/src/org/libspark/thread/utils/ParallelExecutor.as
r641 r653 45 45 { 46 46 private var _index:uint; 47 48 /** 49 * @inheritDoc 50 */ 51 override public function interrupt():void 52 { 53 // 元の割り込み処理を呼び出す 54 super.interrupt(); 55 56 // 全てのスレッドに対しても割り込み処理をかける 57 for each (var thread:Thread in _threads) { 58 thread.interrupt(); 59 } 60 } 47 private var _isInterrupted:Boolean = false; 61 48 62 49 /** … … 96 83 // 次にまたこのメソッドが実行されるよう設定してリターンする 97 84 next(waitThreads); 98 // ちなみに割り込みが発生しても無視する99 interrupted( waitThreads);85 // 割り込み処理 86 interrupted(interruptThreads); 100 87 return; 101 88 } … … 104 91 // ここまで到達した場合全てのスレッドの実行が終了している 105 92 } 93 94 /** 95 * 割り込み処理 96 * 97 * @private 98 */ 99 private function interruptThreads():void 100 { 101 // はじめての割り込みである場合 102 if (!_isInterrupted) { 103 // 全てのスレッドに対して割り込み処理をかける 104 for each (var thread:Thread in _threads) { 105 thread.interrupt(); 106 } 107 _isInterrupted = true; 108 } 109 // すべてのスレッドの終了を待つ 110 waitThreads(); 111 } 106 112 } 107 113 } as3/Thread/trunk/src/org/libspark/thread/utils/SerialExecutor.as
r641 r653 46 46 private var _index:uint; 47 47 private var _current:Thread; 48 private var _isInterrupted:Boolean = false;49 50 /**51 * @inheritDoc52 */53 override public function interrupt():void54 {55 // 元の割り込み処理を呼び出す56 super.interrupt();57 58 // 現在実行されているスレッドがあればそれにも割り込み処理をかける59 if (_current != null) {60 _current.interrupt();61 }62 63 // 割り込まれた64 _isInterrupted = true;65 }66 48 67 49 /** … … 96 78 } 97 79 // もしくは割り込まれた場合は終了する 98 if ( _isInterrupted) {80 if (checkInterrupted()) { 99 81 return; 100 82 } … … 111 93 thread.join(); 112 94 95 // 割り込まれた場合 96 interrupted(runInterrupted); 97 113 98 // スレッドが終了した際に再びこのメソッドが実行されるよう設定 114 99 next(runThread); 115 100 } 101 102 /** 103 * 割り込み処理 104 * 105 * @private 106 */ 107 private function runInterrupted():void 108 { 109 // 現在実行中のスレッドに対して割り込みをかける 110 _current.interrupt(); 111 // そのスレッドの終了を待って終了する 112 _current.join(); 113 } 116 114 } 117 115 }
