Tcl_CreateTimerHandler(3)
π NAME π
Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler β bestie, these two literally call a procedure at a given time β°β¨
This is all from the Tcl Library Procedures manual, page Tcl_CreateTimerHandler(3), and no cap we're going through every single bit of it.
β¨ SYNOPSIS β¨
#include <tcl.h>
Tcl_TimerToken
Tcl_CreateTimerHandler(milliseconds, proc, clientData)
Tcl_DeleteTimerHandler(token)
Like, that's the whole vibe right there π«Ά
π ARGUMENTS π
int milliseconds(in) β how many milliseconds we're waiting beforeprocgets invoked. So it's giving "patience, queen" πTcl_TimerProc *proc(in) β the procedure to invoke oncemillisecondshave elapsed. This is the main character of the whole operation fr fr.void *clientData(in) β an arbitrary one-word value you pass along toproc. Literally anything, your call, no judgement πΈTcl_TimerToken token(in) β the token for a previously created timer handler. It's the return value from some previous call toTcl_CreateTimerHandler, iykyk π
π¦ DESCRIPTION π¦
Okay so Tcl_CreateTimerHandler arranges for proc to be invoked at a time milliseconds milliseconds in the future. That's it, that's the whole thing. The callback to proc will be made by Tcl_DoOneEvent, which means Tcl_CreateTimerHandler is only useful in programs that dispatch events through Tcl_DoOneEvent or through Tcl commands such as vwait. If your program isn't doing that, this function is just standing there being gorgeous with nothing to do π
And bestie, listen: the call toprocmay not be made at the exact time given bymilliseconds. It will be made at the next opportunity after that time. For example, ifTcl_DoOneEventis not called until long after the time has elapsed, or if there are other pending events to process before the call toproc, then the call toprocwill be delayed. She's not late, she's just busy processing other events π
proc should have arguments and a return value that match the type Tcl_TimerProc:
typedef void Tcl_TimerProc(
void *clientData);
The clientData parameter to proc is a copy of the clientData argument given to Tcl_CreateTimerHandler when the callback was created. Typically, clientData points to a data structure containing application-specific information about what to do in proc. So like, it's your little backpack of context that gets handed over πβ¨
π deleting a timer, the sad part π
Tcl_DeleteTimerHandler may be called to delete a previously created timer handler. It deletes the handler indicated by token so that no call to proc will be made β the plan is cancelled, the vibe is called off, nothing happens π
If that handler no longer exists (e.g. because the time period has already elapsed and proc has been invoked), then Tcl_DeleteTimerHandler does nothing. It's fine. It's fine. Everything's fine π§
Also important: the tokens returned by Tcl_CreateTimerHandler never have a value of NULL, so if NULL is passed to Tcl_DeleteTimerHandler then the procedure does nothing. Safe, harmless, iconic behavior honestly π
π SEE ALSO π
β KEYWORDS β
callback, clock, handler, timer β that's the whole mood board π
And that's the page, bestie π This was the Tcl Library Procedures manual, page Tcl_CreateTimerHandler(3), and it's from Tcl version 7.5 β go forth and schedule your callbacks, you absolute legend π«Άβ¨
π¦ where this page comes from
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- fedora 43: tcl-doc 1:9.0.2-1.fc43 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- fedora 44: tcl-doc 1:9.0.2-1.fc44 Β· TCL AND GPL-3.0-or-later WITH Bison-exception-2.2 AND BSD-3-Clause
- nixos 26.05: tcl 9.0.3
- Copyright (c) 1990 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms