Couchbase C Client  3.1.2
Asynchronous C Client for Couchbase

Detailed Description

Functions for synchronous I/O execution.

The lcb_wait() family of functions allow to control when the library sends the operations to the cluster and waits for their execution.

It is also possible to use non-blocking I/O with the library


lcb_STATUS lcb_tick_nowait (lcb_INSTANCE *instance)
lcb_STATUS lcb_wait (lcb_INSTANCE *instance, lcb_WAITFLAGS flags)
Wait for completion of scheduled operations. More...
void lcb_breakout (lcb_INSTANCE *instance)
Forcefully break from the event loop. More...
int lcb_is_waiting (lcb_INSTANCE *instance)
Check if instance is blocked in the event loop More...


enum  lcb_WAITFLAGS
 Flags for lcb_wait() More...

Function Documentation

◆ lcb_tick_nowait()

lcb_STATUS lcb_tick_nowait ( lcb_INSTANCE instance)

This function will cause a single "tick" in the underlying event loop, causing operations whose I/O can be executed immediately to be sent to the server.

Like lcb_wait(), callbacks for operations may be delivered here, however some operations may be left incomplete if their I/O could not be processed immediately. This function is intended as an optimization for large batches of operations - so that some I/O can be completed during the batching process itself, and only the remainder of those operations (which would have blocked) will be completed with lcb_wait() (which should be invoked after the batch).

This function is mainly useful if there is a significant delay in time between each scheduling function, in which I/O may be completed during these gaps (thereby emptying the socket's kernel write buffer, and allowing for new operations to be added after the interval). Calling this function for batches where all data is available up-front may actually make things slower.

You must call lcb_wait() at least one after any batch of operations to ensure they have been completed. This function is provided as an optimization only.
LCB_ERR_SDK_FEATURE_UNAVAILABLE if the event loop does not support the "tick" mode.

◆ lcb_wait()

lcb_STATUS lcb_wait ( lcb_INSTANCE instance,
lcb_WAITFLAGS  flags 

◆ lcb_breakout()

void lcb_breakout ( lcb_INSTANCE instance)

Forcefully break from the event loop.

You may call this function from within any callback to signal to the library that it return control to the function calling lcb_wait() as soon as possible. Note that if there are pending functions which have not been processed, you are responsible for calling lcb_wait() a second time.

instancethe instance to run the event loop for.

◆ lcb_is_waiting()

int lcb_is_waiting ( lcb_INSTANCE instance)

Check if instance is blocked in the event loop

instancethe instance to run the event loop for.
non-zero if nobody is waiting for IO interaction

Enumeration Type Documentation


Flags for lcb_wait()


Behave like the old lcb_wait()


Do not check pending operations before running the event loop.

By default lcb_wait() will traverse the server list to check if any operations are pending, and if nothing is pending the function will return without running the event loop. This is usually not necessary for applications which already only call lcb_wait() when they know they have scheduled at least one command.