SystemDaemonThreaded
abstract class SystemDaemonThreaded extends SystemDaemon
Base Class for a Threaded System Daemon
Constants
private THREAD_CONFIG_CHECK_INTERVAL |
|
Properties
array | $cmd_params | from SystemDaemon | |
string | $daemon_name | from SystemDaemon | |
string | $module_name | from SystemDaemon | |
mixed | $view | from SystemDaemon | |
int | $sleep_between_process | from SystemDaemon | |
int | $process_counter | from SystemDaemon | |
mixed | $mod_registry | from SystemDaemon | |
mixed | $shutdown | from SystemDaemon | |
string | $sleeping | from SystemDaemon | |
array | $messages | from SystemDaemon | |
protected float|int | $requestCacheClearingTime | from SystemDaemon | |
protected int | $lastRequestCacheClearingTime | from SystemDaemon | |
protected int | $maxThreadCount | ||
protected | $threadLifetimeCycles |
Methods
Gets called if a thread finishes It can be used e.g. to clean up unfinished work in case of an ABORTED exit status
Gets calles before a Thread is being started Use this place to e.g. initialize/update static caches which can be reused in each thread to avoid init within each thread
Gets called during each management process loop It can be used e.g. to clean up unfinished work in case of an ABORTED exit status
Gets called within a thread before running the execite loop
Gets called within a thread before stopping thread
Returns the number of required Threads By default this is the maximum number of configured threads but best-practise is to make this adaptive by your workload and use your queue length to adjust the thread count to reduce the number of running threads during low load situations
Returns an array with all threads which should run and their options By default we use the configured number of Max Threads
Default Entry Point for each Thread which covers the basic abort checks and thread lifetime handling
Returns true if the daemon process is in the shutdown phase to be ended
Gets called if a thread exits with an error code It can be used e.g. to clean up unfinished work in case of an ABORTED exit status
Main Daemon Process used to orchestrate all working threads Important: Must not contain any blocking operations
No description
Details
in
SystemDaemon at line 102
__construct()
put your comment there.
..
in
SystemDaemon at line 359
__destruct()
No description
at line 222
void
afterThreadFinished(string $threadIdentifier, int $threadProcessId, int $exitStatus)
Gets called if a thread finishes It can be used e.g. to clean up unfinished work in case of an ABORTED exit status
at line 210
void
beforeNewThreadStart(string $threadIdentifier, array $threadOptions)
Gets calles before a Thread is being started Use this place to e.g. initialize/update static caches which can be reused in each thread to avoid init within each thread
at line 241
void
beforeProcess()
Gets called during each management process loop It can be used e.g. to clean up unfinished work in case of an ABORTED exit status
at line 31
beginThread()
Gets called within a thread before running the execite loop
at line 38
endThread()
Gets called within a thread before stopping thread
at line 199
int
getRequiredThreadCount()
Returns the number of required Threads By default this is the maximum number of configured threads but best-practise is to make this adaptive by your workload and use your queue length to adjust the thread count to reduce the number of running threads during low load situations
at line 181
array
getThreadConfig()
Returns an array with all threads which should run and their options By default we use the configured number of Max Threads
in
SystemDaemon at line 332
halt()
No description
at line 60
final bool
handleProcessThread(string $threadIdentifier, array $threadOptions)
Default Entry Point for each Thread which covers the basic abort checks and thread lifetime handling
in
SystemDaemon at line 224
bool
isShutdown()
Returns true if the daemon process is in the shutdown phase to be ended
in
SystemDaemon at line 165
void
load_module_instances(mixed $module)
No description
in
SystemDaemon at line 309
message(string $message, string $level = Logger::INFO)
Daemon message
in
SystemDaemon at line 324
onStartup()
Gets called once on daemon startup Use this place to prepare daemon
at line 233
void
onThreadError(string $threadIdentifier, int $threadProcessId, int $exitStatus)
Gets called if a thread exits with an error code It can be used e.g. to clean up unfinished work in case of an ABORTED exit status
at line 101
final
process()
Main Daemon Process used to orchestrate all working threads Important: Must not contain any blocking operations
at line 50
abstract bool
processThread(string $threadIdentifier, array $threadOptions)
No description
in
SystemDaemon at line 367
protected
registerSignalHandler()
No description
in
SystemDaemon at line 110
static
restart_all()
Restart all Daemons
in
SystemDaemon at line 381
signalHandler(int $signo, mixed $siginfo)
No description
in
SystemDaemon at line 183
start()
No description
in
SystemDaemon at line 125
static
start_all(bool $if_running_on_this_node = false)
Start all Daemons
in
SystemDaemon at line 145
static
stop_all(bool $if_running_on_this_node = false)
Stop all Daemons