Shutdown command queue #233

Closed
opened 2021-03-13 11:34:27 +00:00 by jamie · 5 comments
jamie commented 2021-03-13 11:34:27 +00:00 (Migrated from git.hazaar.io)

I'm starting to try and do more things in the __destruct() function to make things speedy. Thing is, if the object goes out of scope before the buffer gets spat at the browser, it's not going to make much difference.

What I need to do is have a shutdown command queue. That is, these things that want to do things on destruct so they don't impact load times, can register the command in the queue then once the app shuts down and flushes the buffer, these things will execute. That way they should be able to take as long as they want without actually affecting the user experience.

I'm starting to try and do more things in the `__destruct()` function to make things speedy. Thing is, if the object goes out of scope before the buffer gets spat at the browser, it's not going to make much difference. What I need to do is have a shutdown command queue. That is, these things that want to do things on destruct so they don't impact load times, can register the command in the queue then once the app shuts down and flushes the buffer, these things will execute. That way they should be able to take as long as they want without actually affecting the user experience.
jamie commented 2021-04-05 22:45:04 +00:00 (Migrated from git.hazaar.io)

changed the description

changed the description
jamie commented 2021-04-08 01:22:11 +00:00 (Migrated from git.hazaar.io)

Turns out, this is already built into PHP. See: https://www.php.net/manual/en/function.register-shutdown-function.php. So I will use this issue/branch to update some things in Hazaar that are currently executing in destructors that should probably be executed using this method.

Turns out, this is already built into PHP. See: https://www.php.net/manual/en/function.register-shutdown-function.php. So I will use this issue/branch to update some things in Hazaar that are currently executing in destructors that should probably be executed using this method.
jamie commented 2022-08-04 07:24:01 +00:00 (Migrated from git.hazaar.io)

I am now creating register_shutdown_task() which is similar to the PHP function, except it takes an optional unique ID so that tasks can be performed only once. This is handy for things like Hazaar\Cache which can do a cleanup on files or a database or something but we MAY have multiple cache instances but we only want to cleanup once.

I am now creating `register_shutdown_task()` which is similar to the PHP function, except it takes an optional unique ID so that tasks can be performed only once. This is handy for things like `Hazaar\Cache` which can do a cleanup on files or a database or something but we MAY have multiple cache instances but we only want to cleanup once.
jamie commented 2022-08-04 07:26:12 +00:00 (Migrated from git.hazaar.io)

mentioned in merge request !150

mentioned in merge request !150
jamie commented 2022-08-04 07:26:15 +00:00 (Migrated from git.hazaar.io)

mentioned in commit 6b825233c92948fda32ff28bd360243ac72d42a5

mentioned in commit 6b825233c92948fda32ff28bd360243ac72d42a5
jamie (Migrated from git.hazaar.io) closed this issue 2022-08-04 07:26:16 +00:00
jamie self-assigned this 2025-09-04 01:15:24 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: hazaar/framework#233
No description provided.