src/Pure/Concurrent/task_queue.ML
changeset 44340 3b859b573f1a
parent 44338 700008399ee5
child 44341 a93d25fb14fc
equal deleted inserted replaced
44339:eda6aef75939 44340:3b859b573f1a
   247 (* cancel -- peers and sub-groups *)
   247 (* cancel -- peers and sub-groups *)
   248 
   248 
   249 fun cancel (Queue {groups, jobs}) group =
   249 fun cancel (Queue {groups, jobs}) group =
   250   let
   250   let
   251     val _ = cancel_group group Exn.Interrupt;
   251     val _ = cancel_group group Exn.Interrupt;
   252     val running =
   252     val (tasks, threads) =
   253       Tasks.fold (fn (task, _) =>
   253       Tasks.fold (fn (task, _) => fn (tasks, threads) =>
   254           (case get_job jobs task of Running thread => cons (task, thread) | _ => I))
   254           (case get_job jobs task of
   255         (get_tasks groups (group_id group)) [];
   255             Running thread => (task :: tasks, insert Thread.equal thread threads)
   256     val threads = fold (insert Thread.equal o #2) running [];
   256           | Passive _ => (task :: tasks, threads)
       
   257           | _ => (tasks, threads)))
       
   258         (get_tasks groups (group_id group)) ([], []);
   257     val _ = List.app Simple_Thread.interrupt_unsynchronized threads;
   259     val _ = List.app Simple_Thread.interrupt_unsynchronized threads;
   258   in map #1 running end;
   260   in tasks end;
   259 
   261 
   260 fun cancel_all (Queue {jobs, ...}) =
   262 fun cancel_all (Queue {jobs, ...}) =
   261   let
   263   let
   262     fun cancel_job (task, (job, _)) (groups, running) =
   264     fun cancel_job (task, (job, _)) (groups, running) =
   263       let
   265       let