From patchwork Sun Apr 25 13:18:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shubhanshu Saxena X-Patchwork-Id: 27356 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3153442iob; Sun, 25 Apr 2021 06:19:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFbeZHn2eQSs2Ppn2+uLpDSGO/GZYw11ENATvlsAkQ2/A7fv5PRdxVlu2AHNIFCcMp24BP X-Received: by 2002:a17:906:d154:: with SMTP id br20mr13567719ejb.28.1619356767193; Sun, 25 Apr 2021 06:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619356767; cv=none; d=google.com; s=arc-20160816; b=eximDWhIpke1Sq/Fx3/adHyJPE9GxvY5gVZ7uAK5b/3uRTRGNRiYDP+6kEfmHhiMY+ Y3NwdD8fATQ7LPkFcao17xZS+T5iL+k9tZ1eJnAlJYxdearMTIJrfbG80cF2h0T/nKWP MzwPrB0aZN6H4xNRqQaLWw4MXOQxEsPdj5FcMmwpasJcr30F85jhRhh6pOAkf9Km/jax X3xHDko1gOggqylNfia14uIKBDPM/hrdPYWxmswbXOCb/OGdJj/Fhpcr4pSAw7t0sJv5 IJ3K/IYgQRyz36IvVvJSgkxLWpHIY8u3s/bZFRZ4Jfb1LTs7KR57TkxSb8cO5kNLifTc I5sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=oVEiWyRduP2tOVhNuoF9IKAZkTOlpyDWraDEtlgi4e8=; b=sMV0iBTFAZxcFSBTsH/g+8TJ3do7PQ0HSnZGHYRZrPFBrRrGBtRMB7ZxeboZ+Ay0SR CbgOrzZjNuAJTBVriMQEpMJpyJMxaqGGl/L1nEVK0h99nc+lpq5sPphlFbA7G+80xDCh Am2rwzN6rpw/BLaE7GwdbD5yRVKcU6VU6Lp8VSa7BJzK9BdWrxfZ7Yg10INHn1Y2DJXp taGyn3ETzgiW/7gAm0a8e+xlu1O4KE+V+uwXr+u1YVCBfNvXXxSoz41dHFgdLYqytRt0 BapgsnYA0illdESPp1uZD3olM0EwRtSxQR/8/CNuX2Cczc65QqQ8YHFkKmViRpGWjzLy Ir/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Vu0ZyWdJ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id q9si10689441ejz.674.2021.04.25.06.19.26; Sun, 25 Apr 2021 06:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20161025 header.b=Vu0ZyWdJ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 80F7168804D; Sun, 25 Apr 2021 16:19:22 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C4EEA680633 for ; Sun, 25 Apr 2021 16:19:15 +0300 (EEST) Received: by mail-pg1-f178.google.com with SMTP id p12so38338271pgj.10 for ; Sun, 25 Apr 2021 06:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=j1vMo3AWfmS3kXgEFFFLp1rg8mHMRQkBvFvnosmoUjg=; b=Vu0ZyWdJWZhyeWYzqFGzHJl1aq6r44iC7X8WADbI+dtt3NBNWjrTm2FF9Ca0RkuDA+ 6gNln1a9eDx7ZG4Kkv0Gn2MDt8XE9z+LohEnaDV3zvSXx2tuAq6askmUHVQiSaAMnoqr sxulf8JjWSP8RMqGwrmGpb90iLrA+FYrp2jsdpd+f2QXd5iAT3yVGRvRU+xhQMIG9X8Z RFiZFuG/cmJTmDaA4s0vDzGjivjbxchP9JYG1trAg5jZA2dhEx3nej+LjL8BtDG2YthP 4DIVaAkdtiBNsZVeZ54MPiASYL7+2XJdAF3pKWlz0yxpF7SN1Xf0oAC6CJsoEiBMcm4J PNAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=j1vMo3AWfmS3kXgEFFFLp1rg8mHMRQkBvFvnosmoUjg=; b=QPqZu/hIwS/Fe8MDNluWT6+no4IdDZSDRr7MKkmJD5ovPbWx0mQJIu/jfDx4peJmk5 8tnkKNJyCgm2BMGJVNjUZM6IqqlEqK6XmSGHOeOzwfGNjpOhTO/OPvoKOb8aUEc/SGi8 nUbgX4PE8nPpp0GfqA4FO4iCGKeKCYAG7pF0r3ZgzjwSszTTqUOqSXvtI52ux3Qo1aPX WsBAFMl26G4BTqxJ58NxzrsHZ/cFSYbhphNP9wQBwjgVyorM8xUUt+tjTTsFfKyE4GyQ EUbGzJXD/SmrkRmY9k9McsUfR+p5hixWHii2stVJFc6lafd6db2a5lK47IEF7jMFaoI+ prDg== X-Gm-Message-State: AOAM53153WAQEPNEcVLLqOCDv0Dgx9b6KaDJMug4ApP0uVEQqzTZb5i/ zNtfn68KGYU0xPJE1B+gybw0E0ZkJL0= X-Received: by 2002:a65:5808:: with SMTP id g8mr12365794pgr.137.1619356753638; Sun, 25 Apr 2021 06:19:13 -0700 (PDT) Received: from localhost.localdomain ([117.212.37.136]) by smtp.googlemail.com with ESMTPSA id w9sm8886557pfn.213.2021.04.25.06.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Apr 2021 06:19:13 -0700 (PDT) From: Shubhanshu Saxena To: ffmpeg-devel@ffmpeg.org Date: Sun, 25 Apr 2021 18:48:47 +0530 Message-Id: <20210425131846.47597-1-shubhanshu.e01@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavfilter: Add Documentation to SafeQueue X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: shubhanshu02 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: fMKYsfhbXv/9 From: shubhanshu02 Adds documentation to queue.h in libavfilter/dnn Signed-off-by: shubhanshu02 --- libavfilter/dnn/safe_queue.h | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/libavfilter/dnn/safe_queue.h b/libavfilter/dnn/safe_queue.h index 36d6daabaf..577a02e24d 100644 --- a/libavfilter/dnn/safe_queue.h +++ b/libavfilter/dnn/safe_queue.h @@ -21,16 +21,76 @@ #ifndef AVFILTER_DNN_SAFE_QUEUE_H #define AVFILTER_DNN_SAFE_QUEUE_H +/** + * Double-ended queue with mutex locks ensuring + * data consistency while multithreading. + */ typedef struct SafeQueue SafeQueue; +/** + * @brief Create and initialize a SafeQueue instance. + * + * @return Pointer to the SafeQueue + * @retval NULL if initialization fails + */ SafeQueue *ff_safe_queue_create(void); + +/** + * @brief Destroy the SafeQueue instance. + * It also frees all elements of the queue, + * destroys the mutex and condition variable. + */ void ff_safe_queue_destroy(SafeQueue *sq); +/** + * @brief Return the length of the SafeQueue + */ size_t ff_safe_queue_size(SafeQueue *sq); +/** + * @brief Add data to the head of queue in the + * SafeQueue after locking mutex. After adding + * the data, it signals the condition variable + * and unlocks the mutex. It increases the length + * of queue in the SafeQueue by one. + * + * @param sq pointer to the SafeQueue + * @param v data to be added + * @return The length of the queue + * @retval 0 if the queue is not initialized + * @retval -1 if new entry cannot be created + */ int ff_safe_queue_push_front(SafeQueue *sq, void *v); + +/** + * @brief Add data to the tail of queue in the + * SafeQueue after locking mutex. After adding + * the data, it signals the condition variable + * and unlocks the mutex. It increases the length + * of queue in the SafeQueue by one. + * + * @param sq pointer to the SafeQueue + * @param v data to be added + * @return The length of the queue + * @retval 0 if the queue is not initialized + * @retval -1 if new entry cannot be created + */ int ff_safe_queue_push_back(SafeQueue *sq, void *v); +/** + * @brief Remove and free first element from + * the queue in SafeQueue. Before removing, it + * waits for the condition variable to signal and + * acquires the mutex. Finally, it signals the + * condition and unlocks the mutex. + * It shrinks the length of queue in the SafeQueue + * by one. + * + * @param sq pointer to the SafeQueue. + * @return The value of first element as void. + * If a null pointer or empty queue is passed, + * it returns NULL + */ void *ff_safe_queue_pop_front(SafeQueue *sq); #endif