org.scalatest.concurrent.Interruptor.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scalatest_2.9.0 Show documentation
Show all versions of scalatest_2.9.0 Show documentation
ScalaTest is a free, open-source testing toolkit for Scala and Java
programmers.
/* * Copyright 2001-2012 Artima, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.scalatest.concurrent /** * Strategy for interrupting an operation after a timeout expires. * *
Unit. */ object Interruptor { /** * Factory method for an* An instance of this trait is used for configuration when using traits *
*/ trait Interruptor extends Function1[Thread, Unit] { thisInterruptor => /** * Interrupts an operation. * *Timeouts
andTimeLimitedTests
. ** This method may do anything to attempt to interrupt an operation, or even do nothing. * When called by
*/ def apply(testThread: Thread): Unit /* override def compose[U](g: U => Thread): Interruptor = new Interruptor { def apply(u: U) = thisInterruptor.apply(g(u)) } */ } /** * Companion object that provides a factory method for anfailAfter
method of traitTimeouts
, the passed *Thread
will represent the main test thread. ThisThread
is * passed in case it is useful, but need not be used by implementations of this method. *Interruptor
defined * in terms of a function from a function of typeThread
toInterruptor
defined in terms of a function from a function of * typeThread
to Unit. * * When thisapply
method is invoked, it will invoke the passed function'sapply
* method, forwarding along the passedThread
. * * @param fun the function representing the interruption strategy */ def apply(fun: Thread => Unit) = new Interruptor { def apply(testThread: Thread) { fun(testThread) } } }