GPGME hides the complexity of the communication between the
library and the crypto engine. The price of this convenience is that
the calling thread can block arbitrary long waiting for the data
returned by the crypto engine. In single-threaded programs, in
particular if they are interactive, this is an unwanted side-effect.
gpgme_wait is used without the hang option being
enabled, it might be called unnecessarily often, wasting CPU time that
could be used otherwise.
The I/O callback interface described in this section lets the user take control over what happens when. GPGME will provide the user with the file descriptors that should be monitored, and the callback functions that should be invoked when a file descriptor is ready for reading or writing. It is then the user’s responsibility to decide when to check the file descriptors and when to invoke the callback functions. Usually this is done in an event loop, that also checks for events in other parts of the program. If the callback functions are only called when the file descriptors are ready, GPGME will never block. This gives the user more control over the program flow, and allows to perform other tasks when GPGME would block otherwise.
By using this advanced mechanism, GPGME can be integrated smoothly into GUI toolkits like GTK+ even for single-threaded programs.
|• I/O Callback Interface:||How I/O callbacks are registered.|
|• Registering I/O Callbacks:||How to use I/O callbacks for a context.|
|• I/O Callback Example:||An example how to use I/O callbacks.|
|• I/O Callback Example GTK+:||How to use GPGME with GTK+.|
|• I/O Callback Example GDK:||How to use GPGME with GDK.|
|• I/O Callback Example Qt:||How to use GPGME with Qt.|