Skip to content

Commit 2fff4fb

Browse files
Improve doc
1 parent c1dda33 commit 2fff4fb

3 files changed

Lines changed: 12 additions & 27 deletions

File tree

include/msd/blocking_iterator.hpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
namespace msd {
1010

1111
/**
12-
* @brief An iterator that block the current thread, waiting to fetch elements from the channel.
12+
* @brief An iterator that blocks the current thread, waiting to fetch elements from the channel.
1313
*
14-
* Used to implement channel range-based for loop.
14+
* @details Used to implement channel range-based for loop.
1515
*
1616
* @tparam Channel Type of channel being iterated.
1717
*/
@@ -80,7 +80,6 @@ class blocking_iterator {
8080
* @brief Makes iteration continue until the channel is closed and empty.
8181
*
8282
* @param other Another blocking_iterator to compare with.
83-
*
8483
* @return true if the channel is not closed or not empty (continue iterating).
8584
* @return false if the channel is closed and empty (stop iterating).
8685
*/
@@ -95,7 +94,7 @@ class blocking_iterator {
9594
/**
9695
* @brief An output iterator pushes elements into a channel. Blocking until the channel is not full.
9796
*
98-
* Used to integrate with standard algorithms that require an output iterator.
97+
* @details Used to integrate with standard algorithms that require an output iterator.
9998
*
10099
* @tparam Channel Type of channel being iterated.
101100
*/
@@ -137,11 +136,9 @@ class blocking_writer_iterator {
137136
/**
138137
* @brief Writes an element into the channel, blocking until space is available.
139138
*
140-
* @note There is no effect if the channel is closed.
141-
*
142139
* @param value The value to be written into the channel.
143-
*
144140
* @return The iterator itself.
141+
* @note There is no effect if the channel is closed.
145142
*/
146143
blocking_writer_iterator& operator=(reference value)
147144
{
@@ -152,12 +149,12 @@ class blocking_writer_iterator {
152149
/**
153150
* @brief Not applicable (handled by operator=).
154151
*
152+
* @return The iterator itself.
153+
*
155154
* @note It's uncommon to return a reference to an iterator, but I don't want to return a value from the channel.
156155
* This iterator is supposed to be used only to write values.
157156
* I don't know if it's a terrible idea or not, but it looks related to the issue with MSVC
158157
* in the Transform test in tests/channel_test.cpp.
159-
*
160-
* @return The iterator itself.
161158
*/
162159
blocking_writer_iterator& operator*() { return *this; }
163160

@@ -183,9 +180,7 @@ class blocking_writer_iterator {
183180
* @brief Creates a blocking iterator for the given channel.
184181
*
185182
* @tparam Channel Type of channel being iterated.
186-
*
187183
* @param chan Reference to the channel this iterator will iterate over.
188-
*
189184
* @return A blocking iterator for the specified channel.
190185
*/
191186
template <typename Channel>

include/msd/channel.hpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class closed_channel : public std::runtime_error {
3131
/**
3232
* @brief Thread-safe container for sharing data between threads.
3333
*
34-
* Implements a blocking input iterator.
34+
* - Not movable, not copyable.
35+
* - Includes a blocking input iterator.
3536
*
3637
* @tparam T The type of the elements.
3738
*/
@@ -85,9 +86,7 @@ class channel {
8586
* @brief Pushes an element into the channel.
8687
*
8788
* @tparam Type The type of the elements.
88-
*
8989
* @param value The element to be pushed into the channel.
90-
*
9190
* @return true If an element was successfully pushed into the channel.
9291
* @return false If the channel is closed.
9392
*/
@@ -114,7 +113,6 @@ class channel {
114113
* @brief Pops an element from the channel.
115114
*
116115
* @param out Reference to the variable where the popped element will be stored.
117-
*
118116
* @return true If an element was successfully read from the channel.
119117
* @return false If the channel is closed and empty.
120118
*/
@@ -210,9 +208,6 @@ class channel {
210208
*/
211209
iterator end() noexcept { return blocking_iterator<channel<T>>{*this, true}; }
212210

213-
/**
214-
* Channel cannot be copied or moved.
215-
*/
216211
channel(const channel&) = delete;
217212
channel& operator=(const channel&) = delete;
218213
channel(channel&&) = delete;

include/msd/static_channel.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ namespace msd {
1616
/**
1717
* @brief Thread-safe container for sharing data between threads.
1818
*
19-
* Allocates elements on the stack.
20-
* Does not throw exceptions.
21-
* Implements a blocking input iterator.
19+
* - Allocates elements on the stack.
20+
* - Does not throw exceptions.
21+
* - Not movable, not copyable.
22+
* - Includes a blocking input iterator.
2223
*
2324
* @tparam T The type of the elements.
2425
* @tparam Capacity The maximum number of elements the channel can hold before blocking.
@@ -52,9 +53,7 @@ class static_channel {
5253
* @brief Pushes an element into the channel.
5354
*
5455
* @tparam Type The type of the elements.
55-
*
5656
* @param value The element to be pushed into the channel.
57-
*
5857
* @return true If an element was successfully pushed into the channel.
5958
* @return false If the channel is closed.
6059
*/
@@ -82,7 +81,6 @@ class static_channel {
8281
* @brief Pops an element from the channel.
8382
*
8483
* @param out Reference to the variable where the popped element will be stored.
85-
*
8684
* @return true If an element was successfully read from the channel.
8785
* @return false If the channel is closed and empty.
8886
*/
@@ -179,9 +177,6 @@ class static_channel {
179177
*/
180178
iterator end() noexcept { return blocking_iterator<static_channel<T, Capacity>>{*this, true}; }
181179

182-
/**
183-
* Channel cannot be copied or moved.
184-
*/
185180
static_channel(const static_channel&) = delete;
186181
static_channel& operator=(const static_channel&) = delete;
187182
static_channel(static_channel&&) = delete;

0 commit comments

Comments
 (0)