NVIDIA DeepStream SDK API Reference
9.1 Release
sources/apps/sample_apps/deepstream-transfer-learning-app/concurrent_queue.h
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: Copyright (c) 2020-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3
* SPDX-License-Identifier: Apache-2.0
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#pragma once
19
20
#include <queue>
21
#include <mutex>
22
26
template
<
typename
T>
27
class
ConcurrentQueue
28
{
29
public
:
30
void
push
(
const
T &elm);
31
T
pop
();
32
bool
is_empty
();
33
34
private
:
35
std::queue<T> queue_;
36
std::mutex mutex_;
37
};
38
39
template
<
typename
T>
40
void
ConcurrentQueue<T>::push
(
const
T &elm)
41
{
42
mutex_.lock();
43
queue_.push(elm);
44
mutex_.unlock();
45
}
46
47
template
<
typename
T>
48
T
ConcurrentQueue<T>::pop
()
49
{
50
mutex_.lock();
51
T elm = queue_.front();
52
queue_.pop();
53
mutex_.unlock();
54
return
elm;
55
}
56
57
template
<
typename
T>
58
bool
ConcurrentQueue<T>::is_empty
()
59
{
60
mutex_.lock();
61
bool
res = queue_.empty();
62
mutex_.unlock();
63
return
res;
64
}
ConcurrentQueue
Simple concurrent Queue class using an stl queue.
Definition:
sources/apps/sample_apps/deepstream-transfer-learning-app/concurrent_queue.h:27
ConcurrentQueue::push
void push(const T &elm)
Definition:
sources/apps/sample_apps/deepstream-transfer-learning-app/concurrent_queue.h:40
ConcurrentQueue::pop
T pop()
Definition:
sources/apps/sample_apps/deepstream-transfer-learning-app/concurrent_queue.h:48
ConcurrentQueue::is_empty
bool is_empty()
Definition:
sources/apps/sample_apps/deepstream-transfer-learning-app/concurrent_queue.h:58
Privacy Policy
|
Manage My Privacy
|
Do Not Sell or Share My Data
|
Terms of Service
|
Accessibility
|
Corporate Policies
|
Product Security
|
Contact
© 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
NVIDIA Confidential | Subject to Change | For test and development only.
Thu Jul 9 2026 11:48:18 | PR-09318-R32