equal
deleted
inserted
replaced
11 object Par_List |
11 object Par_List |
12 { |
12 { |
13 def managed_results[A, B](f: A => B, xs: List[A]): List[Exn.Result[B]] = |
13 def managed_results[A, B](f: A => B, xs: List[A]): List[Exn.Result[B]] = |
14 if (xs.isEmpty || xs.tail.isEmpty) xs.map(x => Exn.capture { f(x) }) |
14 if (xs.isEmpty || xs.tail.isEmpty) xs.map(x => Exn.capture { f(x) }) |
15 else { |
15 else { |
16 val state = Synchronized((List.empty[Future[B]], false)) |
16 val state = Synchronized[(List[Future[B]], Boolean)]((Nil, false)) |
17 |
17 |
18 def cancel_other(self: Int = -1): Unit = |
18 def cancel_other(self: Int = -1): Unit = |
19 state.change { case (futures, canceled) => |
19 state.change { case (futures, canceled) => |
20 if (!canceled) { |
20 if (!canceled) { |
21 for ((future, i) <- futures.iterator.zipWithIndex if i != self) |
21 for ((future, i) <- futures.iterator.zipWithIndex if i != self) |