}
vapi_error_e
-vapi_dispatch_one (vapi_ctx_t ctx)
+vapi_dispatch_one_timedwait (vapi_ctx_t ctx, u32 wait_time)
{
VAPI_DBG ("vapi_dispatch_one()");
void *msg;
uword size;
svm_q_conditional_wait_t cond =
- vapi_is_nonblocking (ctx) ? SVM_Q_NOWAIT : SVM_Q_WAIT;
- vapi_error_e rv = vapi_recv (ctx, &msg, &size, cond, 0);
+ vapi_is_nonblocking (ctx) ? (wait_time ? SVM_Q_TIMEDWAIT : SVM_Q_NOWAIT) :
+ SVM_Q_WAIT;
+ vapi_error_e rv = vapi_recv (ctx, &msg, &size, cond, wait_time);
if (VAPI_OK != rv)
{
VAPI_DBG ("vapi_recv failed with rv=%d", rv);
return rv;
}
+vapi_error_e
+vapi_dispatch_one (vapi_ctx_t ctx)
+{
+ return vapi_dispatch_one_timedwait (ctx, 0);
+}
+
vapi_error_e
vapi_dispatch (vapi_ctx_t ctx)
{
*/
vapi_error_e vapi_wait (vapi_ctx_t ctx);
+/**
+ * @brief pick next message sent by vpp and call the appropriate callback
+ *
+ * @note if using block mode, it will be blocked indefinitely until the next
+ * msg available. If using non-blocking mode, it will block for time_wait
+ * seconds until the next msg available if time_wait > 0, or does not block if
+ * time_wait == 0.
+ *
+ * @return VAPI_OK on success, other error code on error
+ */
+vapi_error_e vapi_dispatch_one_timedwait (vapi_ctx_t ctx, u32 wait_time);
+
/**
* @brief pick next message sent by vpp and call the appropriate callback
*
*
* @note the dispatch loop is interrupted if any error is encountered or
* returned from the callback, in which case this error is returned as the
- * result of vapi_dispatch. In this case it might be necessary to call dispatch
- * again to process the remaining messages. Returning VAPI_EUSER from
- * a callback allows the user to break the dispatch loop (and distinguish
- * this case in the calling code from other failures). VAPI never returns
- * VAPI_EUSER on its own.
+ * result of vapi_dispatch. In this case it might be necessary to call
+ * dispatch again to process the remaining messages. Returning VAPI_EUSER
+ * from a callback allows the user to break the dispatch loop (and
+ * distinguish this case in the calling code from other failures). VAPI never
+ * returns VAPI_EUSER on its own.
*
* @return VAPI_OK on success, other error code on error
*/