C.3 GC Caching
GCs are cached by the library to allow merging of independent change requests to the same GC into single protocol requests. This is typically called a write-back cache. Any extension routine whose behavior depends on the contents of a GC must flush the GC cache to make sure the server has up-to-date contents in its GC.
The FlushGC()
macro checks the dirty bits in
the library’s GC structure and calls _XFlushGCCache
if any elements have changed. The FlushGC()
macro is
defined as follows:
FlushGC(display, gc) Display *display; GC gc;
- display
Specifies the connection to the X server.
- gc
Specifies the GC.
Note that if you extend the GC to add additional resource ID
components, you should ensure that the library stub sends the change
request immediately. This is because a client can free a resource
immediately after using it, so if you only stored the value in the cache
without forcing a protocol request, the resource might be destroyed
before being set into the GC. You can use the
_XFlushGCCache
procedure to force the cache to be
flushed. The _XFlushGCCache
procedure is defined as
follows:
_XFlushGC()Cache(display, gc) Display *display; GC gc;
- display
Specifies the connection to the X server.
- gc
Specifies the GC.
Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.