Class Tasks
Where background work runs: the named TaskExecutors, and two
shorthands for running something once.
Tasks.platform(new Runnable() { public void run() { rebuildIndex(); } });
Tasks.virtual(new Runnable() { public void run() { pingWebhooks(); } });
Whose executors
Every server has its own executors, sized from its own configuration and
stopped with it: two servers in one process -- or one stopped and started
again -- must not share a pool, or stopping one would shut down the executor
the other's scheduler and @Async methods still submit to. The calls
here are static because generated code makes them, so they find the server by
the calling thread: a request thread, a task thread and a scheduled job all
carry the server they work for, and so does the thread that builds and starts
the beans. A thread that carries none -- one the program started itself --
gets the most recently started server that is still running.
Which thread
A virtual thread is the cheaper one, and the right one for work that waits
on sockets -- a PostgreSQL or MySQL query or an HTTP call parks it. It is the
wrong one for SQLite or file work: those block the HOST thread under the
virtual thread, and every other virtual thread on that host with it. See
com.codename1.backend.annotations.ThreadKind.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic TaskExecutorThe executor callednameof the calling thread's server, created on first use.static ListThe executors of every running server, for a listing.static ListexecutorsOf(Collection servers) The executors of the servers inserversonly -- what a metric of the measured servers reads.static voidRunstaskonce on the default pool of platform threads.static voidshutdown(long waitMillis) Stops the executors of the calling thread's server, waiting up towaitMillisin total for what is running.static voidRunstaskonce on a virtual thread, or a platform one where there are none.
-
Field Details
-
AUTO
public static final int AUTO- See Also:
-
VIRTUAL
public static final int VIRTUAL- See Also:
-
PLATFORM
public static final int PLATFORM- See Also:
-
DEFAULT
-
SCHEDULING
The executor scheduled jobs use when they name none.- See Also:
-
-
Method Details
-
executor
-
virtual
Runstaskonce on a virtual thread, or a platform one where there are none. -
platform
Runstaskonce on the default pool of platform threads. -
executors
The executors of every running server, for a listing. -
executorsOf
The executors of the servers inserversonly -- what a metric of the measured servers reads.executors()also answers for a server that turned metrics off, whose queues would then appear in another server's telemetry, the one built-in metric counting work from a server that opted out. -
shutdown
public static void shutdown(long waitMillis) Stops the executors of the calling thread's server, waiting up towaitMillisin total for what is running.
-