X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fsvm%2Fqueue.h;h=9d21b24d7ea258650443a75e7c25163037d5f37f;hb=refs%2Fchanges%2F86%2F33186%2F3;hp=75e63a49319951c0e8aad3e7a999d74c9d4e00d0;hpb=c470e22f12a68f06990f57f12f551fee50b6bb0d;p=vpp.git diff --git a/src/svm/queue.h b/src/svm/queue.h index 75e63a49319..9d21b24d7ea 100644 --- a/src/svm/queue.h +++ b/src/svm/queue.h @@ -2,7 +2,7 @@ *------------------------------------------------------------------ * svm_queue.h - shared-memory queues * - * Copyright (c) 2009 Cisco and/or its affiliates. + * Copyright (c) 2009-2019 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -39,12 +39,13 @@ typedef struct _svm_queue typedef enum { - SVM_Q_WAIT = 0, /**< blocking call - must be used only in combination - with condvars */ + SVM_Q_WAIT = 0, /**< blocking call - best used in combination with + condvars, for eventfds we don't yield the cpu */ SVM_Q_NOWAIT, /**< non-blocking call - works with both condvar and eventfd signaling */ SVM_Q_TIMEDWAIT, /**< blocking call, returns on signal or time-out - - must be used only in combination with condvars */ + best used in combination with condvars, with + eventfds we don't yield the cpu */ } svm_q_conditional_wait_t; /** @@ -76,11 +77,30 @@ int svm_queue_sub (svm_queue_t * q, u8 * elem, svm_q_conditional_wait_t cond, u32 time); int svm_queue_sub2 (svm_queue_t * q, u8 * elem); void svm_queue_lock (svm_queue_t * q); +void svm_queue_send_signal (svm_queue_t * q, u8 is_prod); void svm_queue_unlock (svm_queue_t * q); int svm_queue_is_full (svm_queue_t * q); int svm_queue_add_nolock (svm_queue_t * q, u8 * elem); int svm_queue_sub_raw (svm_queue_t * q, u8 * elem); +/** + * Wait for queue event + * + * Must be called with mutex held. + */ +void svm_queue_wait (svm_queue_t * q); + +/** + * Timed wait for queue event + * + * Must be called with mutex held. + * + * @param q svm queue + * @param timeout time in seconds + * @return 0 on success, ETIMEDOUT on timeout or an error + */ +int svm_queue_timedwait (svm_queue_t * q, double timeout); + /** * Add element to queue with mutex held * @param q queue