Skip to content

Commit

Permalink
Make service pluggable so developers can plug-in custom executor-serv…
Browse files Browse the repository at this point in the history
…ice (#1993)
  • Loading branch information
andreak authored Jul 20, 2021
1 parent bb8fb65 commit 8e74e41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/util/src/main/scala/net/liftweb/util/Schedule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,17 @@ sealed trait Schedule extends Loggable {


/** The underlying <code>java.util.concurrent.ScheduledExecutor</code> */
private var service: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(TF)
@volatile var buildService: () => ScheduledExecutorService = () => Executors.newSingleThreadScheduledExecutor(TF)

private var service: ScheduledExecutorService = buildService()
private var pool = buildExecutor()

/**
* Re-create the underlying <code>SingleThreadScheduledExecutor</code>
*/
def restart: Unit = synchronized
{ if ((service eq null) || service.isShutdown)
service = Executors.newSingleThreadScheduledExecutor(TF)
service = buildService()
if ((pool eq null) || pool.isShutdown)
pool = buildExecutor()
}
Expand Down

0 comments on commit 8e74e41

Please sign in to comment.