src/Pure/Concurrent/future.ML
changeset 62359 6709e51d5c11
parent 61556 0d4ee4168e41
child 62505 9e2a65912111
equal deleted inserted replaced
62357:ab76bd43c14a 62359:6709e51d5c11
   197 fun cancel_later group = (*requires SYNCHRONIZED*)
   197 fun cancel_later group = (*requires SYNCHRONIZED*)
   198  (Unsynchronized.change canceled (insert Task_Queue.eq_group group);
   198  (Unsynchronized.change canceled (insert Task_Queue.eq_group group);
   199   broadcast scheduler_event);
   199   broadcast scheduler_event);
   200 
   200 
   201 fun interruptible_task f x =
   201 fun interruptible_task f x =
   202   (if Multithreading.available then
   202   Multithreading.with_attributes
   203     Multithreading.with_attributes
   203     (if is_some (worker_task ())
   204       (if is_some (worker_task ())
   204      then Multithreading.private_interrupts
   205        then Multithreading.private_interrupts
   205      else Multithreading.public_interrupts)
   206        else Multithreading.public_interrupts)
   206     (fn _ => f x)
   207       (fn _ => f x)
       
   208    else interruptible f x)
       
   209   before Multithreading.interrupted ();
   207   before Multithreading.interrupted ();
   210 
   208 
   211 
   209 
   212 (* worker threads *)
   210 (* worker threads *)
   213 
   211 
   649 
   647 
   650 
   648 
   651 (* shutdown *)
   649 (* shutdown *)
   652 
   650 
   653 fun shutdown () =
   651 fun shutdown () =
   654   if not Multithreading.available then ()
   652   if is_some (worker_task ()) then
   655   else if is_some (worker_task ()) then
       
   656     raise Fail "Cannot shutdown while running as worker thread"
   653     raise Fail "Cannot shutdown while running as worker thread"
   657   else
   654   else
   658     SYNCHRONIZED "shutdown" (fn () =>
   655     SYNCHRONIZED "shutdown" (fn () =>
   659       while scheduler_active () do
   656       while scheduler_active () do
   660        (do_shutdown := true;
   657        (do_shutdown := true;