Snooze

Event loop for handling notifications from multiple threads at once

LGPL-3.0 License

Downloads
394K
Stars
18
Committers
3
Snooze - 0.5.0 Latest Release

Published by dktapps over 1 year ago

Changes since 0.4.x

General

  • PHP 8.1 or newer is now required.
  • ext-pmmpthread 6.0 or newer is now required.

API changes

  • SleeperHandler::addNotifier() now returns SleeperHandlerEntry. This is a thread-safe object used to create SleeperNotifier, and should be passed to the destination thread.
  • SleeperHandler::addNotifier() no longer accepts SleeperNotifier. Notifiers are now created using SleeperHandlerEntry::createNotifier().
  • SleeperHandler::removeNotifier() now accepts int $notifierId. This allows the main thread to retain only the notifier ID for later cleanup, saving memory.
  • SleeperNotifier is no longer thread-safe, and must be instantiated within the destination thread using SleeperHandlerEntry::createNotifier(). Since the notification delivery does not require the notifier itself to be a thread-safe object, this allows for better performance by avoiding unnecessary locking and the inherent overhead of thread-safe objects.
Snooze - 0.4.0

Published by dktapps almost 2 years ago

Changes since 0.3.1

  • pthreads ^5.0 is now required.
Snooze - 0.3.1

Published by dktapps almost 3 years ago

Changes since 0.3.0

  • Accept pthreads ~3.2.0 || ^4.0.
Snooze - 0.1.6

Published by dktapps almost 3 years ago

Changes since 0.1.5

  • Accept pthreads ~3.2.0 || ^4.0.
Snooze - 0.3.0

Published by dktapps over 3 years ago

Changes since 0.2.0

  • SleeperHandler now only accepts Closure for handlers, not callable. (You can use Closure::fromCallable() to convert a callable to a closure.)
  • Improved performance of SleeperNotifier->wakeupSleeper() (less locking).
  • SleeperHandler no longer keeps references to SleeperNotifier instances (not needed). NotifierEntry has therefore been removed.
Snooze - 0.2.0

Published by dktapps over 3 years ago

Changes since 0.1.5

  • The use of a thread-safe map for tracking notifications (instead of flags on each notifier) improves performance substantially:
    • Notification processing with large numbers of notifiers is much faster, since it's not required to synchronize with and bruteforce-search for notifiers causing a wakeup (less locks, and also less CPU time wasted).
    • Less locks are required during delivery of notifications (locks only required on the shared object and not on notifiers).