GMainLoop: The GLib Main Loop

Description Usage Arguments Details Value Author(s) References

Description

GLib provides an event-loop to all GLib-based libraries and applications. RGtk2 is one such library.

Usage

1
2
3
gTimeoutAdd(interval, f, data = NULL)
gIdleAdd(f, data = NULL)
gSourceRemove(id)

Arguments

interval

The time interval which determines the frequency of the handler call

f

An R function that is called by the loop

data

Any R object that is passed to the R function as the last parameter

id

The source id obtained when adding a handler

Details

The RGtk2 user has limited control over the event loop, but it still possible to register handlers as either timeout or idle tasks. A handler may be any R function, though it must return TRUE as long as it wants to stay connected to the loop.

Timeout tasks are performed once per some specified interval of time. Use gTimeoutAdd to register such a handler.

When the event loop is idle (not busy) it will execute the idle handlers, which may be registered with gIdleAdd.

If one needs to externally remove a handler from the loop, gSourceRemove will serve this purpose.

Value

gIdleAdd and gTimeoutAdd both return a source id that may be used to remove the handler later.

Author(s)

Michael Lawrence

References

https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html


RGtk2 documentation built on Oct. 14, 2021, 5:08 p.m.

Related to GMainLoop in RGtk2...