Skip to content

Commit 8a5e062

Browse files
authored
Merge pull request #4 from wicyn/2.x
build(unbounded_queue): 修复 clang-tidy bugprone-* 与 clang-format 违规
2 parents 47cfbc2 + 9b483e8 commit 8a5e062

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

taskflowlite/core/executor.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class Executor : public Immovable<Executor> {
306306
/// 分片数量 = bit_width(num_workers),随 worker 数对数增长。
307307
struct alignas(2 * cache_line_size) Buffer {
308308
std::mutex mutex;
309-
UnboundedQueue<Work*> queue{2 * TFL_DEFAULT_QUEUE_SIZE};
309+
UnboundedQueue<Work*> queue{2LL * TFL_DEFAULT_QUEUE_SIZE};
310310
};
311311

312312
// 2x cache line 对齐:防止多线程修改 m_num_topologies 时产生伪共享

taskflowlite/core/unbounded_queue.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ class AtomicRingBuffer : public Immovable<AtomicRingBuffer<Tp>> {
6363
/// @param bottom 当前队尾位置
6464
/// @param top 当前队头位置
6565
/// @return 新缓冲区指针
66-
[[nodiscard]] TFL_FORCE_INLINE AtomicRingBuffer* resize(std::int64_t bottom, std::int64_t top) const;
66+
[[nodiscard]] TFL_FORCE_INLINE AtomicRingBuffer* resize(std::int64_t bottom, std::int64_t top) const; // NOLINT(bugprone-easily-swappable-parameters)
6767

6868
/// @brief 扩容:创建足够容纳额外元素的新缓冲区
6969
/// @param bottom 当前队尾位置
7070
/// @param top 当前队头位置
7171
/// @param n 额外需要容纳的元素数量
7272
/// @return 新缓冲区指针
73-
[[nodiscard]] TFL_FORCE_INLINE AtomicRingBuffer* resize(std::int64_t bottom, std::int64_t top, std::size_t n) const;
73+
[[nodiscard]] TFL_FORCE_INLINE AtomicRingBuffer* resize(std::int64_t bottom, std::int64_t top, std::size_t n) const; // NOLINT(bugprone-easily-swappable-parameters)
7474

7575
private:
7676
std::int64_t m_cap; ///< 实际容量(2 的倍数)
@@ -93,7 +93,7 @@ class UnboundedQueue : public Immovable<UnboundedQueue<Tp>> {
9393

9494
/// @brief 构造函数,创建指定初始容量的队列
9595
/// @param cap 初始容量(默认 2 倍默认队列大小)
96-
explicit UnboundedQueue(std::int64_t cap = 2 * TFL_DEFAULT_QUEUE_SIZE);
96+
explicit UnboundedQueue(std::int64_t cap = 2LL * TFL_DEFAULT_QUEUE_SIZE);
9797

9898
/// @brief 析构函数,释放当前缓冲区和历史缓冲区
9999
~UnboundedQueue() noexcept;
@@ -186,7 +186,7 @@ TFL_FORCE_INLINE Tp AtomicRingBuffer<Tp>::load(std::int64_t index) const noexcep
186186

187187
template <typename Tp>
188188
requires std::is_pointer_v<Tp>
189-
TFL_FORCE_INLINE AtomicRingBuffer<Tp>* AtomicRingBuffer<Tp>::resize(
189+
TFL_FORCE_INLINE AtomicRingBuffer<Tp>* AtomicRingBuffer<Tp>::resize( // NOLINT(bugprone-easily-swappable-parameters)
190190
std::int64_t bottom, std::int64_t top) const {
191191
auto* ptr = new AtomicRingBuffer{2 * m_cap};
192192
for (std::int64_t i = top; i != bottom; ++i) {
@@ -197,7 +197,7 @@ TFL_FORCE_INLINE AtomicRingBuffer<Tp>* AtomicRingBuffer<Tp>::resize(
197197

198198
template <typename Tp>
199199
requires std::is_pointer_v<Tp>
200-
TFL_FORCE_INLINE AtomicRingBuffer<Tp>* AtomicRingBuffer<Tp>::resize(
200+
TFL_FORCE_INLINE AtomicRingBuffer<Tp>* AtomicRingBuffer<Tp>::resize( // NOLINT(bugprone-easily-swappable-parameters)
201201
std::int64_t bottom, std::int64_t top, std::size_t n) const {
202202
// 确保新容量为 2 的幂次方且足够容纳现有元素 + 新增元素
203203
std::int64_t const new_cap = std::bit_ceil(m_cap + n);

0 commit comments

Comments
 (0)