TCL_CREATETIMERHANDLER(3tcl)
π Tcl_CreateTimerHandler β bestie, it's a timer, it's a callback, it's a whole vibe π
okay so this is a page from the Tcl Library Procedures manual, and it's about the two functions that let you say "hey Tcl, run this lil function for me later, mmkay?" β Tcl_CreateTimerHandler and Tcl_DeleteTimerHandler. Their whole job is literally just call a procedure at a given time. That's it. That's the girl. π
β¨ NAME β¨
Tcl_CreateTimerHandler, Tcl_DeleteTimerHandler β call a procedure at a given time π
πΈ SYNOPSIS πΈ
#include <tcl.h>
Tcl_TimerToken
Tcl_CreateTimerHandler(milliseconds, proc, clientData)
Tcl_DeleteTimerHandler(token)
π¦ ARGUMENTS π¦
int milliseconds(in) β how many milliseconds we're waiting before we invokeproc. the countdown, the anticipation, the drama πTcl_TimerProc *proc(in) β the procedure we're gonna invoke oncemillisecondshave elapsed. your main character function, basically πvoid *clientData(in) β an arbitrary one-word value that gets passed toproc. literally whatever you want, no judgement, it's giving "bring your own baggage" πTcl_TimerToken token(in) β the token for a timer handler you made earlier (i.e. the return value from some previous call toTcl_CreateTimerHandler). your lil receipt, keep it safe π§Ύ
π DESCRIPTION π
Tcl_CreateTimerHandler arranges for proc to be invoked at a time milliseconds milliseconds in the future. slay. β¨
But here's the tea, bestie: the callback to proc is made by Tcl_DoOneEvent, so 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 the event-dispatch thing, this function is just gonna sit there looking cute and doing nothing. π
And the call to proc may not be made at the exact time given by milliseconds β it will be made at the next opportunity after that time. For example, if Tcl_DoOneEvent is not called until long after the time has elapsed, or if there are other pending events to process before the call to proc, then the call to proc will be delayed. so likeβ¦ it's a vibe, not a stopwatch. β°
proc should have arguments and 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 you're passing your own lil info bundle through the void and getting it handed right back. iconic. π«Ά
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. 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. no error, no drama, just nothing. π
The tokens returned byTcl_CreateTimerHandlernever have a value ofNULL, so ifNULLis passed toTcl_DeleteTimerHandlerthen the procedure does nothing. safe. protected. unbothered. π
π SEE ALSO π
β KEYWORDS β
callback, clock, handler, timer
and that's the whole page, bestie!! you ate π this was Tcl 7.5 of the Tcl Library Procedures, filed under Tcl_CreateTimerHandler(3tcl) β go forth and schedule your callbacks responsibly, ily, mwah πβ¨π¦
π¦ where this page comes from
- debian trixie: tcl9.0-doc 9.0.1+dfsg-2
- ubuntu questing: tcl9.0-doc 9.0.2+dfsg-1
- ubuntu resolute: tcl9.0-doc 9.0.3+dfsg-1
- ubuntu stonking: tcl9.0-doc 9.0.4+dfsg-1
- 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