Tcl_DoWhenIdle (3)
invoke a procedure when there are no pending events
SYNOPSIS
#include <tcl.h>
Tcl_DoWhenIdle(proc, clientData)
Tcl_CancelIdleCall(proc, clientData)
ARGUMENTS
Tcl_IdleProc clientData
Tcl_IdleProc *proc in
Procedure to invoke.
ClientData clientData in
Arbitrary one-word value to pass to proc.
DESCRIPTION
Tcl_DoWhenIdle arranges for proc to be invoked
when the application becomes idle. The application is
considered to be idle when Tcl_DoOneEvent has been
called, couldn't find any events to handle, and is about
to go to sleep waiting for an event to occur. At this
point all pending Tcl_DoWhenIdle handlers are
invoked. For each call to Tcl_DoWhenIdle there will
be a single call to proc; after proc is
invoked the handler is automatically removed.
Tcl_DoWhenIdle is only usable in programs that
use Tcl_DoOneEvent to dispatch events.
Proc should have arguments and result that match the
type Tcl_IdleProc:
typedef void Tcl_IdleProc(ClientData clientData);
The clientData parameter to proc is a copy of the clientData
argument given to Tcl_DoWhenIdle. Typically, clientData
points to a data structure containing application-specific information about
what proc should do.
Tcl_CancelIdleCall
may be used to cancel one or more previous
calls to Tcl_DoWhenIdle: if there is a Tcl_DoWhenIdle
handler registered for proc and clientData, then it
is removed without invoking it. If there is more than one
handler on the idle list that refers to proc and clientData,
all of the handlers are removed. If no existing handlers match
proc and clientData then nothing happens.
Tcl_DoWhenIdle is most useful in situations where
(a) a piece of work will have to be done but (b) it's
possible that something will happen in the near future
that will change what has to be done or require something
different to be done. Tcl_DoWhenIdle allows the
actual work to be deferred until all pending events have
been processed. At this point the exact work to be done
will presumably be known and it can be done exactly once.
For example, Tcl_DoWhenIdle might be used by an editor
to defer display updates until all pending commands have
been processed. Without this feature, redundant redisplays
might occur in some situations, such as the processing of
a command file.
BUGS
At present it is not safe for an idle callback to reschedule itself
continuously. This will interact badly with certain features of Tk
that attempt to wait for all idle callbacks to complete. If you would
like for an idle callback to reschedule itself continuously, it is
better to use a timer handler with a zero timeout period.
KEYWORDS
callback, defer, idle callback
'\"
'\" Copyright (c) 1993 The Regents of the University of California.
'\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
'\"
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
'\" RCS: @(#) $Id: DString.3,v 1.2 1998/09/14 18:39:48 stanton Exp $
'\"
'\" The definitions below are for supplemental macros used in Tcl/Tk
'\" manual entries.
'\"
'\" .AP type name in/out ?indent?
'\" Start paragraph describing an argument to a library procedure.
'\" type is type of argument (int, etc.), in/out is either "in", "out",
'\" or "in/out" to describe whether procedure reads or modifies arg,
'\" and indent is equivalent to second arg of .IP (shouldn't ever be
'\" needed; use .AS below instead)
'\"
'\" .AS ?type? ?name?
'\" Give maximum sizes of arguments for setting tab stops. Type and
'\" name are examples of largest possible arguments that will be passed
'\" to .AP later. If args are omitted, default tab stops are used.
'\"
'\" .BS
'\" Start box enclosure. From here until next .BE, everything will be
'\" enclosed in one large box.
'\"
'\" .BE
'\" End of box enclosure.
'\"
'\" .CS
'\" Begin code excerpt.
'\"
'\" .CE
'\" End code excerpt.
'\"
'\" .VS ?version? ?br?
'\" Begin vertical sidebar, for use in marking newly-changed parts
'\" of man pages. The first argument is ignored and used for recording
'\" the version when the .VS was added, so that the sidebars can be
'\" found and removed when they reach a certain age. If another argument
'\" is present, then a line break is forced before starting the sidebar.
'\"
'\" .VE
'\" End of vertical sidebar.
'\"
'\" .DS
'\" Begin an indented unfilled display.
'\"
'\" .DE
'\" End of indented unfilled display.
'\"
'\" .SO
'\" Start of list of standard options for a Tk widget. The
'\" options follow on successive lines, in four columns separated
'\" by tabs.
'\"
'\" .SE
'\" End of list of standard options for a Tk widget.
'\"
'\" .OP cmdName dbName dbClass
'\" Start of description of a specific option. cmdName gives the
'\" option's name as specified in the class command, dbName gives
'\" the option's name in the option database, and dbClass gives
'\" the option's class in the option database.
'\"
'\" .UL arg1 arg2
'\" Print arg1 underlined, then print arg2 normally.
'\"
'\" RCS: @(#) $Id: man.macros,v 1.2 1998/09/14 18:39:54 stanton Exp $
'\"
'\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
t .wh -1.3i ^B
^l \n(.l
b
'\" # Start an argument description
AP
!"\\$4"" .TP \\$4
\{\
!"\\$2"" .TP \\n()Cu
.TP 15
|