チェンジセット 653

差分発生行の前後
無視リスト:
コミット日時:
2008/06/19 17:12:46 (5 ヶ月前)
コミッタ:
yossy
ログメッセージ:

Thread: SerialExecutor?ParallelExecutor? の割り込み処理がおかしかったので修正

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • as3/Thread/trunk/Thread.as3proj

    r641 r653  
    6969  <!-- Class files to compile (other referenced classes will automatically be included) --> 
    7070  <compileTargets> 
    71     <compile path="samples\progress\Sample.as" /> 
     71    <compile path="samples\urlloader\Sample.as" /> 
    7272  </compileTargets> 
    7373  <!-- Paths to exclude from the Project Explorer tree --> 
  • as3/Thread/trunk/src/org/libspark/thread/utils/ParallelExecutor.as

    r641 r653  
    4545        { 
    4646                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; 
    6148                 
    6249                /** 
     
    9683                                        // 次にまたこのメソッドが実行されるよう設定してリターンする 
    9784                                        next(waitThreads); 
    98                                         // ちなみに割り込みが発生しても無視する 
    99                                         interrupted(waitThreads); 
     85                                        // 割り込み処理 
     86                                        interrupted(interruptThreads); 
    10087                                        return; 
    10188                                } 
     
    10491                        // ここまで到達した場合全てのスレッドの実行が終了している 
    10592                } 
     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                } 
    106112        } 
    107113} 
  • as3/Thread/trunk/src/org/libspark/thread/utils/SerialExecutor.as

    r641 r653  
    4646                private var _index:uint; 
    4747                private var _current:Thread; 
    48                 private var _isInterrupted:Boolean = false; 
    49                  
    50                 /** 
    51                  * @inheritDoc 
    52                  */ 
    53                 override public function interrupt():void 
    54                 { 
    55                         // 元の割り込み処理を呼び出す 
    56                         super.interrupt(); 
    57                          
    58                         // 現在実行されているスレッドがあればそれにも割り込み処理をかける 
    59                         if (_current != null) { 
    60                                 _current.interrupt(); 
    61                         } 
    62                          
    63                         // 割り込まれた 
    64                         _isInterrupted = true; 
    65                 } 
    6648                 
    6749                /** 
     
    9678                        } 
    9779                        // もしくは割り込まれた場合は終了する 
    98                         if (_isInterrupted) { 
     80                        if (checkInterrupted()) { 
    9981                                return; 
    10082                        } 
     
    11193                        thread.join(); 
    11294                         
     95                        // 割り込まれた場合 
     96                        interrupted(runInterrupted); 
     97                         
    11398                        // スレッドが終了した際に再びこのメソッドが実行されるよう設定 
    11499                        next(runThread); 
    115100                } 
     101                 
     102                /** 
     103                 * 割り込み処理 
     104                 *  
     105                 * @private 
     106                 */ 
     107                private function runInterrupted():void 
     108                { 
     109                        // 現在実行中のスレッドに対して割り込みをかける 
     110                        _current.interrupt(); 
     111                        // そのスレッドの終了を待って終了する 
     112                        _current.join(); 
     113                } 
    116114        } 
    117115}