チェンジセット 528
- コミット日時:
- 2008/05/27 20:30:09 (6 ヶ月前)
- ファイル:
凡例:
- 変更無し
- 追加
- 削除
- 更新
- コピー
- 移動
as3/Thread/branches/soumen/src/org/libspark/thread/Thread.as
r527 r528 9 9 import org.libspark.thread.errors.CurrentThreadNotFoundError; 10 10 import org.libspark.thread.errors.IllegalThreadStateError; 11 import org.libspark.thread.errors.InterruptedError; 11 12 12 13 public class Thread extends Monitor … … 229 230 public static function interrupted(func:Function):void 230 231 { 231 232 getCurrentThread()._interruptedHandler = func; 232 233 } 233 234 … … 241 242 public static function checkInterrupted():Boolean 242 243 { 243 return false; 244 // カレントスレッドを取得 245 var current:Thread = getCurrentThread(); 246 247 // 割り込みステータスを取得 248 var status:Boolean = current._isInterrupted; 249 250 // ステータスが設定されている場合はクリア 251 if (status) { 252 current._isInterrupted = false; 253 } 254 255 // ステータスを返す 256 return status; 244 257 } 245 258 … … 254 267 _savedRunHandler = null; 255 268 _timeoutHandler = null; 269 _interruptedHandler = null; 256 270 _waitMonitor = null; 257 271 _joinMonitor = null; … … 263 277 _errorThread = null; 264 278 _eventHandlers = null; 279 _isInterrupted = false; 265 280 } 266 281 … … 273 288 private var _savedRunHandler:Function; 274 289 private var _timeoutHandler:Function; 290 private var _interruptedHandler:Function; 275 291 private var _waitMonitor:IMonitor; 276 292 private var _joinMonitor:IMonitor; … … 282 298 private var _errorThread:Thread; 283 299 private var _eventHandlers:Array; 300 private var _isInterrupted:Boolean; 284 301 285 302 public function get id():uint … … 308 325 public function get isInterrupted():Boolean 309 326 { 310 return false;327 return _isInterrupted; 311 328 } 312 329 … … 416 433 public function interrupt():void 417 434 { 418 435 if (_state == ThreadState.WAITING || _state == ThreadState.TIMED_WAITING) { 436 // 待機中の場合 437 // モニタに対して待機セットから抜けることを伝える 438 _waitMonitor.leave(this); 439 _waitMonitor = null; 440 // state を切り替える 441 _state = _runningState; 442 // 割り込みハンドラがあれば実行関数を割り込みハンドラに設定 443 if (_interruptedHandler != null) { 444 _runHandler = _interruptedHandler; 445 } 446 else { 447 // 割り込みハンドラがなければ例外を発生 448 _error = new InterruptedError(); 449 } 450 } 451 else { 452 // そうでない場合は割り込みステータスを設定 453 _isInterrupted = true; 454 } 419 455 } 420 456
