org.scalatest.concurrent.Signaler.scala Maven / Gradle / Ivy
The newest version!
/* * Copyright 2001-2013 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 signaling an operation after a timeout expires. * *
Unit. */ object Signaler { /** * Factory method for a* An instance of this trait is used for configuration when using traits *
*/ trait Signaler { /** * Signals an operation. * *TimeLimits
andTimeLimitedTests
. ** This method may do anything to attempt to signal or interrupt an operation, or even do nothing. * When called by
*/ def apply(testThread: Thread): Unit } /** * Companion object that provides a factory method for afailAfter
method of traitTimeLimits
, 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. *Singlaer
defined * in terms of a function from a function of typeThread
toSignaller
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 signaling strategy */ def apply(fun: Thread => Unit) = new Signaler { def apply(testThread: Thread): Unit = { fun(testThread) } } /** * ImplicitSignaler
value defining a default signaling strategy for thefailAfter
andcancelAfter
method * of trait [[org.scalatest.concurrent.TimeLimits]]. */ implicit def default: Signaler = DoNotSignal }
© 2015 - 2024 Weber Informatics LLC | Privacy Policy