src/Pure/General/exn.scala
changeset 56862 e6f7ed54d64e
parent 56861 5f827142d89a
child 57831 885888a880fb
equal deleted inserted replaced
56861:5f827142d89a 56862:e6f7ed54d64e
    46     def unapply(exn: Throwable): Boolean = is_interrupt(exn)
    46     def unapply(exn: Throwable): Boolean = is_interrupt(exn)
    47 
    47 
    48     def expose() { if (Thread.interrupted()) throw apply() }
    48     def expose() { if (Thread.interrupted()) throw apply() }
    49     def impose() { Thread.currentThread.interrupt }
    49     def impose() { Thread.currentThread.interrupt }
    50 
    50 
       
    51     def postpone[A](body: => A): Option[A] =
       
    52     {
       
    53       val interrupted = Thread.interrupted
       
    54       val result = capture { body }
       
    55       if (interrupted) impose()
       
    56       result match {
       
    57         case Res(x) => Some(x)
       
    58         case Exn(e) =>
       
    59           if (is_interrupt(e)) { impose(); None }
       
    60           else throw e
       
    61       }
       
    62     }
       
    63 
    51     val return_code = 130
    64     val return_code = 130
    52   }
    65   }
    53 
    66 
    54 
    67 
    55   /* POSIX return code */
    68   /* POSIX return code */