Skip to content

Commit 9174607

Browse files
Align interface of concurrent_queue and concurrent_bounded_queue with concurrent_priority_queue (#396)
* Align interface of concurrent_queue and concurrent_bounded_queue with concurrent_priority_queue - added : - `operator=` with overloads - `assign` method - `swap` - `operator==` - `operator!=` - `std::initializer_list` constructor Signed-off-by: Anton Potapov <[email protected]> Co-authored-by: kboyarinov <[email protected]>
1 parent 8817b35 commit 9174607

File tree

10 files changed

+343
-2
lines changed

10 files changed

+343
-2
lines changed

source/elements/oneTBB/source/containers/concurrent_bounded_queue_cls.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Class Template Synopsis
4545
concurrent_bounded_queue( InputIterator first, InputIterator last,
4646
const allocator_type& alloc = allocator_type() );
4747
48+
concurrent_bounded_queue( std::initializer_list<value_type> init,
49+
const allocator_type& alloc = allocator_type() );
50+
4851
concurrent_bounded_queue( const concurrent_bounded_queue& other );
4952
concurrent_bounded_queue( const concurrent_bounded_queue& other,
5053
const allocator_type& alloc );
@@ -55,6 +58,17 @@ Class Template Synopsis
5558
5659
~concurrent_bounded_queue();
5760
61+
concurrent_bounded_queue& operator=( const concurrent_bounded_queue& other );
62+
concurrent_bounded_queue& operator=( concurrent_bounded_queue&& other );
63+
concurrent_bounded_queue& operator=( std::initializer_list<value_type> init );
64+
65+
template <typename InputIterator>
66+
void assign( InputIterator first, InputIterator last );
67+
68+
void assign( std::initializer_list<value_type> init );
69+
70+
void swap( concurrent_bounded_queue& other );
71+
5872
allocator_type get_allocator() const;
5973
6074
void push( const value_type& value );
@@ -113,6 +127,37 @@ Member functions
113127
concurrent_bounded_queue_cls/unsafe_member_functions.rst
114128
concurrent_bounded_queue_cls/iterators.rst
115129

130+
Non-member functions
131+
--------------------
132+
133+
These functions provides binary comparison and swap operations on ``oneapi::tbb::concurrent_bounded_queue``
134+
objects.
135+
136+
The exact namespace where this function is defined is unspecified, as long as it may be used in
137+
respective operation. For example, an implementation may define the classes and functions
138+
in the same internal namespace and define ``oneapi::tbb::concurrent_bounded_queue`` as a type alias for which
139+
the non-member functions are reachable only via argument-dependent lookup.
140+
141+
.. code:: cpp
142+
143+
template <typename T, typename Allocator>
144+
void swap( concurrent_bounded_queue<T, Allocator>& lhs,
145+
concurrent_bounded_queue<T, Allocator>& rhs );
146+
147+
template <typename T, typename Allocator>
148+
bool operator==( const concurrent_bounded_queue<T, Allocator>& lhs,
149+
const concurrent_bounded_queue<T, Allocator>& rhs );
150+
151+
template <typename T, typename Allocator>
152+
bool operator!=( const concurrent_bounded_queue<T, Allocator>& lhs,
153+
const concurrent_bounded_queue<T, Allocator>& rhs );
154+
155+
.. toctree::
156+
:maxdepth: 1
157+
158+
concurrent_bounded_queue_cls/non_member_swap.rst
159+
concurrent_bounded_queue_cls/non_member_binary_comparisons.rst
160+
116161
Other
117162
-----
118163

source/elements/oneTBB/source/containers/concurrent_bounded_queue_cls/construct_destroy_copy.rst

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Empty container constructors
1818
Constructs an empty ``concurrent_bounded_queue`` with an unbounded capacity.
1919
If provided, uses the allocator ``alloc`` to allocate the memory.
2020

21-
Constructor from the sequence of elements
21+
Constructors from the sequence of elements
2222
------------------------------------------
2323

2424
.. code:: cpp
@@ -33,6 +33,13 @@ Constructor from the sequence of elements
3333
**Requirements**: the type ``InputIterator`` must meet the `InputIterator` requirements from the
3434
``[input.iterators]`` ISO C++ Standard section.
3535

36+
.. code:: cpp
37+
38+
concurrent_bounded_queue( std::initializer_list<value_type> init,
39+
const allocator_type& alloc = allocator_type() );
40+
41+
Equivalent to ``concurrent_bounded_queue(init.begin(), init.end(), alloc)``.
42+
3643
Copying constructors
3744
--------------------
3845

@@ -79,3 +86,65 @@ Destructor
7986
deallocates the used storage.
8087

8188
The behavior is undefined in case of concurrent operations with ``*this``.
89+
90+
Assignment operators
91+
--------------------
92+
93+
.. code:: cpp
94+
95+
concurrent_bounded_queue& operator=( const concurrent_bounded_queue& other );
96+
97+
Replaces all elements in ``*this`` by the copies of the elements in ``other``.
98+
99+
Copy-assigns allocators if ``std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value``
100+
is ``true``.
101+
102+
The behavior is undefined in case of concurrent operations with ``*this`` and ``other``.
103+
104+
**Returns**: a reference to ``*this``.
105+
106+
.. code:: cpp
107+
108+
concurrent_bounded_queue& operator=( concurrent_bounded_queue&& other );
109+
110+
Replaces all elements in ``*this`` by the elements in ``other`` using move semantics.
111+
112+
``other`` is left in a valid, but unspecified state.
113+
114+
Move-assigns allocators if ``std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value``
115+
is ``true``.
116+
117+
The behavior is undefined in case of concurrent operations with ``*this`` and ``other``.
118+
119+
**Returns**: a reference to ``*this``.
120+
121+
.. code:: cpp
122+
123+
concurrent_bounded_queue& operator=( std::initializer_list<value_type> init );
124+
125+
Replaces all elements in ``*this`` by the elements in ``init``.
126+
127+
The behavior is undefined in case of concurrent operations with ``*this``.
128+
129+
**Returns**: a reference to ``*this``.
130+
131+
assign
132+
------
133+
134+
.. code:: cpp
135+
136+
template <typename InputIterator>
137+
void assign( InputIterator first, InputIterator last );
138+
139+
Replaces all elements in ``*this`` be the elements in the half-open interval ``[first, last)``.
140+
141+
The behavior is undefined in case of concurrent operations with ``*this``.
142+
143+
**Requirements**: the type ``InputIterator`` must meet the `InputIterator` requirements from the
144+
``[input.iterators]`` ISO C++ Standard section.
145+
146+
.. code:: cpp
147+
148+
void assign( std::initializer_list<value_type> init );
149+
150+
Equivalent to ``assign(init.begin(), init.end())``.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
2+
..
3+
.. SPDX-License-Identifier: CC-BY-4.0
4+
5+
=============================
6+
Non-member binary comparisons
7+
=============================
8+
9+
.. code:: cpp
10+
11+
template <typename T, typename Allocator>
12+
bool operator==( const concurrent_bounded_queue<T, Allocator>& lhs,
13+
const concurrent_bounded_queue<T, Allocator>& rhs );
14+
15+
Checks if ``lhs`` is equal to ``rhs``, that is they have the same number of elements and ``lhs``
16+
contains all elements from ``rhs``.
17+
18+
**Returns**: ``true`` if ``lhs`` is equal to ``rhs``; ``false``, otherwise.
19+
20+
.. code:: cpp
21+
22+
template <typename T, typename Allocator>
23+
bool operator!=( const concurrent_bounded_queue<T, Allocator>& lhs,
24+
const concurrent_bounded_queue<T, Allocator>& rhs );
25+
26+
Equivalent to ``!(lhs == rhs)``.
27+
28+
**Returns**: ``true`` if ``lhs`` is not equal to ``rhs``; ``false``, otherwise.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.. SPDX-FileCopyrightText: 2019-2020 Intel Corporation
2+
..
3+
.. SPDX-License-Identifier: CC-BY-4.0
4+
5+
===============
6+
Non-member swap
7+
===============
8+
9+
.. code:: cpp
10+
11+
template <typename T, typename Allocator>
12+
void swap( concurrent_bounded_queue<T, Allocator>& lhs,
13+
concurrent_bounded_queue<T, Allocator>& rhs );
14+
15+
Equivalent to ``lhs.swap(rhs)``.

source/elements/oneTBB/source/containers/concurrent_bounded_queue_cls/unsafe_member_functions.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,16 @@ clear
3434
void clear();
3535
3636
Removes all elements from the container.
37+
38+
swap
39+
----
40+
41+
.. code:: cpp
42+
43+
void swap( concurrent_bounded_queue& other );
44+
45+
Swaps contents of ``*this`` and ``other``.
46+
47+
Swaps allocators if ``std::allocator_traits<allocator_type>::propagate_on_container_swap::value`` is ``true``.
48+
49+
Otherwise if ``get_allocator() != other.get_allocator()`` the behavior is undefined.

source/elements/oneTBB/source/containers/concurrent_queue_cls.rst

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Class Template Synopsis
4545
concurrent_queue( InputIterator first, InputIterator last,
4646
const allocator_type& alloc = allocator_type() );
4747
48+
concurrent_queue( std::initializer_list<value_type> init,
49+
const allocator_type& alloc = allocator_type() );
50+
4851
concurrent_queue( const concurrent_queue& other );
4952
concurrent_queue( const concurrent_queue& other, const allocator_type& alloc );
5053
@@ -53,6 +56,17 @@ Class Template Synopsis
5356
5457
~concurrent_queue();
5558
59+
concurrent_queue& operator=( const concurrent_queue& other );
60+
concurrent_queue& operator=( concurrent_queue&& other );
61+
concurrent_queue& operator=( std::initializer_list<value_type> init );
62+
63+
template <typename InputIterator>
64+
void assign( InputIterator first, InputIterator last );
65+
66+
void assign( std::initializer_list<value_type> init );
67+
68+
void swap( concurrent_queue& other );
69+
5670
void push( const value_type& value );
5771
void push( value_type&& value );
5872
@@ -97,6 +111,37 @@ Member functions
97111
concurrent_queue_cls/unsafe_member_functions.rst
98112
concurrent_queue_cls/iterators.rst
99113

114+
Non-member functions
115+
--------------------
116+
117+
These functions provides binary comparison and swap operations on ``oneapi::tbb::concurrent_queue``
118+
objects.
119+
120+
The exact namespace where this function is defined is unspecified, as long as it may be used in
121+
respective operation. For example, an implementation may define the classes and functions
122+
in the same internal namespace and define ``oneapi::tbb::concurrent_queue`` as a type alias for which
123+
the non-member functions are reachable only via argument-dependent lookup.
124+
125+
.. code:: cpp
126+
127+
template <typename T, typename Allocator>
128+
void swap( concurrent_queue<T, Allocator>& lhs,
129+
concurrent_queue<T, Allocator>& rhs );
130+
131+
template <typename T, typename Allocator>
132+
bool operator==( const concurrent_queue<T, Allocator>& lhs,
133+
const concurrent_queue<T, Allocator>& rhs );
134+
135+
template <typename T, typename Allocator>
136+
bool operator!=( const concurrent_queue<T, Allocator>& lhs,
137+
const concurrent_queue<T, Allocator>& rhs );
138+
139+
.. toctree::
140+
:maxdepth: 1
141+
142+
concurrent_queue_cls/non_member_swap.rst
143+
concurrent_queue_cls/non_member_binary_comparisons.rst
144+
100145
Other
101146
-----
102147

source/elements/oneTBB/source/containers/concurrent_queue_cls/construct_destroy_copy.rst

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Empty container constructors
1818
Constructs an empty ``concurrent_queue``. If provided, uses the allocator ``alloc`` to
1919
allocate the memory.
2020

21-
Constructor from the sequence of elements
21+
Constructors from the sequence of elements
2222
------------------------------------------
2323

2424
.. code:: cpp
@@ -33,6 +33,13 @@ Constructor from the sequence of elements
3333
**Requirements**: the type ``InputIterator`` must meet the `InputIterator` requirements from the
3434
``[input.iterators]`` ISO C++ Standard section.
3535

36+
.. code:: cpp
37+
38+
concurrent_queue( std::initializer_list<value_type> init,
39+
const allocator_type& alloc = allocator_type() );
40+
41+
Equivalent to ``concurrent_queue(init.begin(), init.end(), alloc)``.
42+
3643
Copying constructors
3744
--------------------
3845

@@ -68,6 +75,7 @@ Moving constructors
6875

6976
The behavior is undefined in case of concurrent operations with ``other``.
7077

78+
7179
Destructor
7280
----------
7381

@@ -79,3 +87,65 @@ Destructor
7987
deallocates the used storage.
8088

8189
The behavior is undefined in case of concurrent operations with ``*this``.
90+
91+
Assignment operators
92+
--------------------
93+
94+
.. code:: cpp
95+
96+
concurrent_queue& operator=( const concurrent_queue& other );
97+
98+
Replaces all elements in ``*this`` by the copies of the elements in ``other``.
99+
100+
Copy-assigns allocators if ``std::allocator_traits<allocator_type>::propagate_on_container_copy_assignment::value``
101+
is ``true``.
102+
103+
The behavior is undefined in case of concurrent operations with ``*this`` and ``other``.
104+
105+
**Returns**: a reference to ``*this``.
106+
107+
.. code:: cpp
108+
109+
concurrent_queue& operator=( concurrent_queue&& other );
110+
111+
Replaces all elements in ``*this`` by the elements in ``other`` using move semantics.
112+
113+
``other`` is left in a valid, but unspecified state.
114+
115+
Move-assigns allocators if ``std::allocator_traits<allocator_type>::propagate_on_container_move_assignment::value``
116+
is ``true``.
117+
118+
The behavior is undefined in case of concurrent operations with ``*this`` and ``other``.
119+
120+
**Returns**: a reference to ``*this``.
121+
122+
.. code:: cpp
123+
124+
concurrent_queue& operator=( std::initializer_list<value_type> init );
125+
126+
Replaces all elements in ``*this`` by the elements in ``init``.
127+
128+
The behavior is undefined in case of concurrent operations with ``*this``.
129+
130+
**Returns**: a reference to ``*this``.
131+
132+
assign
133+
------
134+
135+
.. code:: cpp
136+
137+
template <typename InputIterator>
138+
void assign( InputIterator first, InputIterator last );
139+
140+
Replaces all elements in ``*this`` be the elements in the half-open interval ``[first, last)``.
141+
142+
The behavior is undefined in case of concurrent operations with ``*this``.
143+
144+
**Requirements**: the type ``InputIterator`` must meet the `InputIterator` requirements from the
145+
``[input.iterators]`` ISO C++ Standard section.
146+
147+
.. code:: cpp
148+
149+
void assign( std::initializer_list<value_type> init );
150+
151+
Equivalent to ``assign(init.begin(), init.end())``.

0 commit comments

Comments
 (0)