Next: , Up: Run Control   [Contents][Index]


7.8.1 Waiting For Completion

Function: gpgme_ctx_t gpgme_wait (gpgme_ctx_t ctx, gpgme_error_t *status, int hang)

The function gpgme_wait continues the pending operation within the context ctx. In particular, it ensures the data exchange between GPGME and the crypto backend and watches over the run time status of the backend process.

If hang is true, the function does not return until the operation is completed or cancelled. Otherwise the function will not block for a long time.

The error status of the finished operation is returned in status if gpgme_wait does not return NULL.

The ctx argument can be NULL. In that case, gpgme_wait waits for any context to complete its operation.

gpgme_wait can be used only in conjunction with any context that has a pending operation initiated with one of the gpgme_op_*_start functions except gpgme_op_keylist_start and gpgme_op_trustlist_start (for which you should use the corresponding gpgme_op_*_next functions). If ctx is NULL, all of such contexts are waited upon and possibly returned. Synchronous operations running in parallel, as well as key and trust item list operations, do not affect gpgme_wait.

In a multi-threaded environment, only one thread should ever call gpgme_wait at any time, regardless of whether ctx is specified or not. This means that all calls to this function should be fully synchronized by locking primitives. It is safe to start asynchronous operations while a thread is running in gpgme_wait.

The function returns the ctx of the context which has finished the operation. If hang is false, and the timeout expires, NULL is returned and *status will be set to 0. If an error occurs, NULL is returned and the error is returned in *status.


Next: Using External Event Loops, Up: Run Control   [Contents][Index]