{"size": 1474, "ext": "scrbl", "max_stars_repo_path": "web-server-doc/web-server/scribblings/timer.scrbl", "max_stars_repo_name": "jessealama/web-server", "max_stars_repo_stars_event_min_datetime": "2015-01-21T08:11:58.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T08:28:39.000Z", "max_issues_repo_path": "web-server-doc/web-server/scribblings/timer.scrbl", "max_issues_repo_name": "jessealama/web-server", "max_issues_repo_issues_event_min_datetime": "2015-01-14T08:06:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-12T14:38:40.000Z", "max_forks_repo_path": "web-server-doc/web-server/scribblings/timer.scrbl", "max_forks_repo_name": "jessealama/web-server", "max_forks_repo_forks_event_min_datetime": "2015-03-05T15:07:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-07-30T18:59:25.000Z"}
{"max_stars_count": 82, "max_issues_count": 105, "max_forks_count": 37, "avg_line_length": 26.8, "max_line_length": 80, "alphanum_fraction": 0.6139755767}
#lang scribble/doc
@(require "web-server.rkt")

@title[#:tag "timer"]{Timers}
@(require (for-label web-server/private/timer))

@defmodule[web-server/private/timer]{

This module provides a functionality for running
procedures after a given amount of time, that may be extended.

@defproc[(timer-manager? [x any/c]) boolean?]{
 Determines if @racket[x] is a timer manager.
}

@defstruct[timer ([tm timer-manager?]
                  [evt evt?]
                  [expire-seconds number?]
                  [action (-> void)])]{
 @racket[evt] is an @racket[alarm-evt] that is ready at @racket[expire-seconds].
 @racket[action] should be called when this @racket[evt] is ready.
}

@defproc[(start-timer-manager)
         timer-manager?]{
 Handles the execution and management of timers.
}

@defproc[(start-timer [tm timer-manager?]
                      [s number?]
                      [action (-> void)])
         timer?]{
 Registers a timer that runs @racket[action] after @racket[s] seconds.
}

@defproc[(reset-timer! [t timer?]
                       [s number?])
         void]{
 Changes @racket[t] so that it will fire after @racket[s] seconds.
}

@defproc[(increment-timer! [t timer?]
                           [s number?])
         void]{
 Changes @racket[t] so that it will fire after @racket[s] seconds from when
 it does now.
}

@defproc[(cancel-timer! [t timer?])
         void]{
 Cancels the firing of @racket[t] ever and frees resources used by @racket[t].
}

}
