Need custom Schedule.service

12 views
Skip to first unread message

Andreas Joseph Krogh

unread,
Jun 3, 2021, 6:04:16 AM6/3/21
to lif...@googlegroups.com, Torstein Tauno Svendsen
Hi all,
 
Today Schedule.service is private and initialized like this:
 
private var service: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor(TF)
...which is quite unfortunate as it makes it impossible to customize.
 
I propose we have a "builder", similar to buildExecutor(), so we can provide a custom ExecutorService, with default using the existing, like this:
@volatile var buildService: () => ScheduledExecutorService =
      () => Executors.newSingleThreadScheduledExecutor(TF)


private var service: ScheduledExecutorService = buildService()
 
This way one can provide a custom ExecutorService in Boot.scala, like this:
 
Schedule.buildService = () => {
   Executors.unconfigurableScheduledExecutorService(
      new CustomScheduledExecutor(1, myThreadFactory)
   )
}
 
What do you guys think?
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963

Matt Farmer

unread,
Jun 3, 2021, 7:26:10 AM6/3/21
to Lift, Torstein Tauno Svendsen
What would cause you to use Schedule.service instead of just constructing your own ExecutorService from scratch?

Could this have any side-effects for actors which need to be single-threaded?


--
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/liftweb/VisenaEmail.46.dd296aae57dca94c.179d118dbf8%40tc7-visena.

Andreas Joseph Krogh

unread,
Jun 3, 2021, 8:08:20 AM6/3/21
to lif...@googlegroups.com
På torsdag 03. juni 2021 kl. 13:26:03, skrev Matt Farmer <ma...@frmr.me>:
What would cause you to use Schedule.service instead of just constructing your own ExecutorService from scratch?
 
I want to be able to use Schedule(someFunc) and have that task run "decorated" (setting ThreadLocal etc. before the task is executed), and also some internal Lift-stuff uses Schedule, like async-renderer/wiring, and I want to control those too.
 
Could this have any side-effects for actors which need to be single-threaded?
 
I doubut it, as LiftActors use LAScheduler.createExecutor. This is actually replacable and we're using a custom, Spring-managed, executorService for this.
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
 

Matt Farmer

unread,
Jun 3, 2021, 8:30:59 PM6/3/21
to Lift
Cool. I’m game for the change you proposed to boot.

 

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

Andreas Joseph Krogh

unread,
Jun 8, 2021, 3:27:37 PM6/8/21
to Matt Farmer, Lift
På fredag 04. juni 2021 kl. 02:30:53, skrev Matt Farmer <ma...@frmr.me>:
Cool. I’m game for the change you proposed to boot.
 
Coolio!
 
 
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
 
Reply all
Reply to author
Forward
0 new messages