Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/actor/src/main/scala/net/liftweb/actor/LAPinger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object LAPinger {
* @param msg The message to send.
* @param delay The number of milliseconds to delay before sending msg
* @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to
* the <code>to<code> Actor after the specified TimeSpan <code>delay</code>.
* the <code>to</code> Actor after the specified <code>delay</code> milliseconds.
*/
def schedule[T](to: SpecializedLiftActor[T], msg: T, delay: Long): ScheduledFuture[Unit] = {
val r = new Callable[Unit] {
Expand Down
41 changes: 19 additions & 22 deletions core/util/src/main/scala/net/liftweb/util/Schedule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import java.util.concurrent._

import actor.ThreadPoolRules
import common._
import scala.concurrent.duration._
import util.Helpers
import util.Helpers.TimeSpan

class ScheduleJBridge {
def schedule: Schedule = Schedule
Expand Down Expand Up @@ -100,28 +100,28 @@ sealed trait Schedule extends Loggable {
* Schedules the sending of a message to occur after the specified delay.
*
* @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to
* the <code>to<code> Actor after the specified TimeSpan <code>delay</code>.
* the <code>to<code> Actor after the specified FiniteDuration <code>delay</code>.
*/
Comment on lines 102 to 104
def schedule[T](to: SimpleActor[T], msg: T, delay: TimeSpan): ScheduledFuture[Unit] =
this.schedule(() => Helpers.tryo( to ! msg ), delay)
def schedule[T](to: SimpleActor[T], msg: T, delay: FiniteDuration): ScheduledFuture[Unit] =
this.schedule(() => Helpers.tryo(to ! msg), delay)

/**
* Schedules the sending of a message to occur after the specified delay.
*
* @return a <code>ScheduledFuture</code> which sends the <code>msg</code> to
* the <code>to<code> Actor after the specified TimeSpan <code>delay</code>.
* the <code>to<code> Actor after the specified FiniteDuration <code>delay</code>.
*/
Comment on lines 111 to 113
def perform[T](to: SimpleActor[T], msg: T, delay: Long): ScheduledFuture[Unit] =
this.schedule(() => Helpers.tryo( to ! msg ), TimeSpan(delay))
this.schedule(() => Helpers.tryo(to ! msg), Duration(delay, TimeUnit.MILLISECONDS))

/**
/**
* Schedules the sending of a message to occur after the specified delay.
*
* @return a <code>ScheduledFuture</code> which applies the function f
* after delay
*/
def perform(f: () => Unit, delay: Long): ScheduledFuture[Unit] =
schedule(f, TimeSpan(delay))
schedule(f, Duration(delay, TimeUnit.MILLISECONDS))


/**
Expand All @@ -130,35 +130,32 @@ sealed trait Schedule extends Loggable {
* @return a <code>ScheduledFuture</code> which executes the function f
* immediately on a worker thread
*/
def apply(f: () => Unit): ScheduledFuture[Unit] = schedule(f, TimeSpan(0))
def apply(f: () => Unit): ScheduledFuture[Unit] = schedule(f, 0.millis)

/**
* Schedules the application of a function
*
* @return a <code>ScheduledFuture</code> which executes the function f
* after the delay
*/
def apply(f: () => Unit, delay: TimeSpan): ScheduledFuture[Unit] =
def apply(f: () => Unit, delay: FiniteDuration): ScheduledFuture[Unit] =
schedule(f, delay)

/**
* Schedules the application of a function
*
* @return a <code>ScheduledFuture</code> which executes the function f
* after the delay
*/
def schedule(f: () => Unit, delay: TimeSpan): ScheduledFuture[Unit] =
def schedule(f: () => Unit, delay: FiniteDuration): ScheduledFuture[Unit] =
synchronized {
val r = new Runnable {
def run(): Unit = {
try {
f.apply()
} catch {
case e: Exception => logger.error(e.getMessage, e)
}
def run(): Unit = {
try { f.apply() }
catch { case e: Exception => logger.error(e.getMessage, e) }
}
}

val fast = new java.util.concurrent.Callable[Unit] {
def call(): Unit = {
try {
Expand All @@ -169,10 +166,10 @@ sealed trait Schedule extends Loggable {
}
}
}

try {
this.restart
service.schedule(fast, delay.millis, TimeUnit.MILLISECONDS)
service.schedule(fast, delay.toMillis, TimeUnit.MILLISECONDS)
} catch {
case e: RejectedExecutionException => throw ActorPingException("ping could not be scheduled", e)
}
Expand Down
Loading
Loading