38 Commits

Author SHA1 Message Date
Dylan K. Taylor
98380e46bf
Ignore non-fatal error types in crash handlers
ErrorToExceptionHandler currently prevents these from appearing by turning them into exceptions, but this won't always be the case.
For example, in the future we may not want to turn ALL types of E_* errors into exceptions (e.g. E_DEPRECATED).
2024-04-02 19:22:40 +01:00
Dylan K. Taylor
1b0ef468f3
CommonThreadPartsTrait: remove outdated documentation
This is now automatically called by the final run(), and the user now only needs to implement onRun(), so they have no business calling this function.
2023-12-21 13:09:05 +00:00
Dylan K. Taylor
b69843a8bd
CommonThreadPartsTrait: add common implementation of quit()
there's no need for the worker specialization here (isShutdown and shutdown are aliased to isJoined and join respectively), and the unstacking is not really desirable either as we previously learned with AsyncPool.
2023-12-21 12:56:51 +00:00
Dylan K. Taylor
03619ebca9
Thread/Worker: Remove duplicated code
Despite the comments, there doesn't seem to be an obvious reason for these to be copy-pasted. Perhaps there was some legacy reason for this with legacy pthreads.
In fact, it looks likely that quit() will probably be able to be traitified too.
2023-12-21 12:44:03 +00:00
Dylan K. Taylor
bf99917f2a
ThreadSafeClassLoader: add native property types 2023-12-20 17:01:20 +00:00
Dylan K. Taylor
710177ceb5
CS
this mistake actually hasn't happened for a while
2023-08-08 15:10:31 +01:00
Dylan K. Taylor
2559d1719f
All pocketmine\thread\Thread now log uncaught exceptions and fatal errors by default 2023-08-08 14:56:54 +01:00
Dylan K. Taylor
2e58387a43
Fixed thread error capture fail in shutdown function
the shutdown handler currently isn't called until join(), which sets isKilled to true and stops the error information from being recorded.
2023-08-08 14:55:53 +01:00
Dylan T
82a5ea9ed3
Allow thread errors and their traces to be properly recorded in crashdumps (#5910)
until now, any thread crash would show as a generic crash since we aren't able to get the trace from the crashed thread directly. This uses some dirty tricks to export a partially serialized stack trace to the main thread, where it can be written into a crashdump.
This enables us to see proper crash information for async tasks in the crash archive (finally!!!) as well as being able to capture RakLib errors properly.
2023-07-26 16:26:03 +01:00
Dylan K. Taylor
4aba9d9725
Absorb pocketmine/classloader into the core code
the only use for this class is to facilitate random runtime plugin loading, and it's not complete even for that purpose.

Since nothing but PM uses pocketmine/classloader anyway, it doesn't make sense to have it outside the core. As with LogPthreads, it's just adding more maintenance work.
2023-05-22 22:52:48 +01:00
Dylan K. Taylor
097feba4d5
Absorb pocketmine/log-pthreads into PM core
this was previously part of the abandoned package pocketmine/spl. It had to be separated in the PM3 days, because RakLib depended on it.

Since RakLib 0.13, RakLib stopped being dependent on or aware of pthreads, so it no longer depends on any thread-related packages.
It's also possible to absorb pocketmine/snooze and pocketmine/classloader back into the core with this in mind.
2023-05-20 16:57:24 +01:00
Dylan K. Taylor
e0630fbb25
pmmpthread support 2023-05-20 01:29:26 +01:00
Dylan K. Taylor
222415859a
Require pthreads ^5.1
This version of pthreads has a substantially improved API, improved
performance, improved memory usage, and much less magical and broken
behaviour.
2023-01-23 20:02:33 +00:00
Dylan K. Taylor
3b6ff3c42b
Apply union types in some places (BC breaks) 2022-11-23 14:03:35 +00:00
Dylan K. Taylor
d4c4ae3d7a
Merge branch 'next-minor' into next-major 2022-08-25 19:27:29 +01:00
Dylan K. Taylor
f75ca312cc
Worker: Unstack tasks in a synchronized block
this prevents any tasks still left in the queue on shutdown getting pulled out by the worker when we're attempting to shut it down.
This led to various race conditions, most notably weird cases where PopulationTask would inexplicably find its expected generator state had not been correctly set up.
2022-08-21 21:57:11 +01:00
Dylan K. Taylor
aa9f8781ff
Merge branch 'next-minor' into next-major 2022-06-07 19:56:26 +01:00
Dylan K. Taylor
b57f0a2b7e
Fixed uninitialized typed properties 2022-06-06 17:23:43 +01:00
Dylan K. Taylor
083a35f970
Modernize property type declarations 2022-06-04 18:16:32 +01:00
Dylan K. Taylor
38d6284671
Use PHP-CS-Fixer to enforce file header presence 2022-06-04 17:34:49 +01:00
Dylan K. Taylor
c0b15de504
Modernize private static property declarations 2022-05-17 21:55:16 +01:00
Dylan K. Taylor
194cb1fb84
phpstan 1.5.1 2022-03-28 17:12:00 +01:00
Dylan K. Taylor
4e956d5d1d
Replace remaining disallowed operators 2022-01-20 19:23:19 +00:00
Jack Honour
58e1e7bd6f
Worker: fixed missing AsyncTask import for documentation (#4719)
OCD from f5c9c02e09f54b53ed4c495c8a0000b54930ccef
2022-01-10 15:12:37 +00:00
Dylan K. Taylor
f5c9c02e09
Improve documentation of Thread and Worker 2021-09-10 15:57:45 +01:00
Dylan K. Taylor
5fbc7681b0
Allow registering multiple ClassLoaders for a thread 2021-07-15 19:00:40 +01:00
Dylan K. Taylor
f6f0938b3b
Merge branch 'stable' 2021-05-21 01:27:35 +01:00
Dylan K. Taylor
6d6f8c3c38 custom threads: use PTHREADS_INHERIT_NONE by default
this has the most reliable behaviour, because some stuff like respect/validation likes to include files unconditionally which declare functions that are already declared, which breaks due to the lack of function autoloading.
2020-12-01 22:32:59 +00:00
Dylan K. Taylor
abe4f1bf25 Merge commit '763c8ebfe3bb8a597768d86040fee130c8fc7ab8'
# Conflicts:
#	resources/vanilla
#	src/pocketmine/Worker.php
#	src/thread/CommonThreadPartsTrait.php
2020-06-26 18:46:01 +01:00
Dylan K. Taylor
3299bc4023 start using pocketmine/errorhandler 2020-05-10 13:04:40 +01:00
Dylan K. Taylor
f9a587d40e imports cleanup 2020-04-28 17:27:38 +01:00
Dylan K. Taylor
ca909ebc1d Merge branch 'next-minor' 2020-03-10 13:05:37 +00:00
Dylan K. Taylor
fb1126797a Merge branch 'stable' 2020-02-07 18:13:55 +00:00
Dylan K. Taylor
67bcc1c0fb phpdoc armageddon for master, pass 1 2020-01-22 11:55:03 +00:00
Dylan K. Taylor
3ee6887792 populate remaining missing return types, using native returns where possible
this is done separately to stable so that stable changes can be integrated easily using an empty merge.
2020-01-19 10:26:35 +00:00
Dylan K. Taylor
cda1143a79 Merge branch 'stable' 2020-01-09 17:17:42 +00:00
Dylan K. Taylor
cbef2bbc51 move ThreadException to pocketmine\thread namespace 2019-10-29 12:42:38 +00:00
Dylan K. Taylor
5499ac620c Removed pocketmine subdirectory, map PSR-4 style 2019-07-30 19:14:57 +01:00