equal
deleted
inserted
replaced
329 let |
329 let |
330 val (alive, dead) = List.partition (Thread.isActive o #1) (! workers); |
330 val (alive, dead) = List.partition (Thread.isActive o #1) (! workers); |
331 val _ = workers := alive; |
331 val _ = workers := alive; |
332 in |
332 in |
333 Multithreading.tracing 0 (fn () => |
333 Multithreading.tracing 0 (fn () => |
334 "SCHEDULE: disposed " ^ string_of_int (length dead) ^ " dead worker threads") |
334 "SCHEDULER: disposed " ^ string_of_int (length dead) ^ " dead worker threads") |
335 end; |
335 end; |
336 |
336 |
337 |
337 |
338 (* worker pool adjustments *) |
338 (* worker pool adjustments *) |
339 |
339 |
396 |
396 |
397 val _ = broadcast scheduler_event; |
397 val _ = broadcast scheduler_event; |
398 in continue end |
398 in continue end |
399 handle exn => |
399 handle exn => |
400 if Exn.is_interrupt exn then |
400 if Exn.is_interrupt exn then |
401 (Multithreading.tracing 1 (fn () => "Interrupt"); |
401 (Multithreading.tracing 1 (fn () => "SCHEDULER: Interrupt"); |
402 List.app cancel_later (cancel_all ()); |
402 List.app cancel_later (cancel_all ()); |
403 broadcast_work (); true) |
403 broadcast_work (); true) |
404 else reraise exn; |
404 else reraise exn; |
405 |
405 |
406 fun scheduler_loop () = |
406 fun scheduler_loop () = |
682 (* shutdown *) |
682 (* shutdown *) |
683 |
683 |
684 fun shutdown () = |
684 fun shutdown () = |
685 if Multithreading.available then |
685 if Multithreading.available then |
686 SYNCHRONIZED "shutdown" (fn () => |
686 SYNCHRONIZED "shutdown" (fn () => |
687 while scheduler_active () do |
687 while scheduler_active () do |
688 (wait scheduler_event; broadcast_work ())) |
688 (Multithreading.tracing 1 (fn () => "SHUTDOWN: wait"); |
|
689 wait scheduler_event; |
|
690 broadcast_work ())) |
689 else (); |
691 else (); |
690 |
692 |
691 |
693 |
692 (*final declarations of this structure!*) |
694 (*final declarations of this structure!*) |
693 val map = map_future; |
695 val map = map_future; |