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.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access