Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cancellation of timer operations #110

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Oct 1, 2024

  1. operations: Add cancel function to <base-operation>.

    * fibers/operations.scm (<base-op>): Rename constructor to
    ‘%make-base-operation’.
    [cancel-fn]: New field.
    (make-base-operation, cancel-other-operations): New procedures.
    (perform-operation)[block]: Define ‘resume’ to call
    ‘cancel-other-operations’ because calling the real ‘resume’.
    * fibers.texi (Operations): Adjust accordingly.
    civodul committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    c5af998 View commit details
    Browse the repository at this point in the history
  2. timer-wheel: Add ‘timer-wheel-remove!’.

    * fibers/timer-wheel.scm (timer-wheel-remove!): New procedure.
    civodul committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    38dbbef View commit details
    Browse the repository at this point in the history
  3. timers: Add cancel function that removes timer wheel entry.

    Fixes wingo#109.
    
    Previously, an operation like:
    
      (choice-operation (sleep-operation 1234) (get-operation channel))
    
    would accumulate timer wheel entries every time the ‘get’ operation wins
    over the ‘sleep’ operation, potentially leading to unbounded memory
    usage (each ‘sleep’ timer and its associated continuation would remain
    on the wheel for 1234 seconds in this case).
    
    This commit fixes it by removing the timer wheel entry as soon as the
    timer operation is canceled.
    
    * fibers/timers.scm (timer-operation)[wheel-entry]: New variable.
    Set it in block function.  Add cancel function.
    * fibers/scheduler.scm (scheduler-timers): Export.
    * tests/cancel-timer.scm: New file.
    * Makefile.am (TESTS): Add it.
    civodul committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    027411a View commit details
    Browse the repository at this point in the history