added README and LICENSE
This commit is contained in:
@@ -1,3 +1,25 @@
|
||||
/*
|
||||
* Copyright (c) 2026 Peisong Xiao
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef THREADWEAVER_WEAVER_H
|
||||
#define THREADWEAVER_WEAVER_H
|
||||
|
||||
@@ -56,7 +78,7 @@ public:
|
||||
tail.store(0, std::memory_order_release);
|
||||
}
|
||||
|
||||
std::size_t size() const noexcept {
|
||||
std::size_t get_size() const noexcept {
|
||||
return ((tail.load(std::memory_order::acquire) + QSIZE_MASK) -
|
||||
head.load(std::memory_order::acquire)) &
|
||||
QSIZE_MASK;
|
||||
@@ -291,23 +313,23 @@ public:
|
||||
|
||||
uint8_t curr = dl.first;
|
||||
|
||||
if (in_queues[curr].size())
|
||||
if (in_queues[curr].get_size())
|
||||
bitmap |= BitmapType(1) << curr;
|
||||
|
||||
do {
|
||||
curr = dl.next[curr];
|
||||
if (in_queues[curr].size())
|
||||
if (in_queues[curr].get_size())
|
||||
bitmap |= BitmapType(1) << curr;
|
||||
} while (curr != dl.last);
|
||||
|
||||
hint.fetch_or(bitmap, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
template <std::size_t thread_id> std::size_t size() const noexcept {
|
||||
template <std::size_t thread_id> std::size_t get_size() const noexcept {
|
||||
static_assert(thread_id < IN_THREAD_CNT,
|
||||
"Thread ID out of bounds");
|
||||
|
||||
return in_queues[thread_id].size();
|
||||
return in_queues[thread_id].get_size();
|
||||
}
|
||||
|
||||
template <std::size_t thread_id> bool is_empty() const noexcept {
|
||||
@@ -510,12 +532,12 @@ public:
|
||||
BorrowedRef<thread_id> get_empty_borrowed_ref() const noexcept {
|
||||
return BorrowedRef<thread_id>();
|
||||
}
|
||||
IndexType free_size() const noexcept { return fs.size(); }
|
||||
template <std::size_t thread_id> std::size_t size() const noexcept {
|
||||
IndexType free_get_size() const noexcept { return fs.get_size(); }
|
||||
template <std::size_t thread_id> std::size_t get_size() const noexcept {
|
||||
static_assert(thread_id < OUT_THREAD_CNT,
|
||||
"Thread ID out of bounds");
|
||||
|
||||
return consumer_queues[thread_id].size();
|
||||
return consumer_queues[thread_id].get_size();
|
||||
}
|
||||
|
||||
FanOutFabricSendResult<BitmapType>
|
||||
@@ -671,9 +693,9 @@ private:
|
||||
OUT_THREAD_CNT>
|
||||
consumer_queues;
|
||||
alignas(CLS) std::atomic<BitmapType> reclaim_hint;
|
||||
struct alignas(CLS) BufferSlot {
|
||||
std::atomic<RefCountType> count;
|
||||
MessageType payload;
|
||||
struct BufferSlot {
|
||||
alignas(CLS) MessageType payload;
|
||||
alignas(CLS) std::atomic<RefCountType> count;
|
||||
};
|
||||
std::array<BufferSlot, BUFFER_SIZE> buffer;
|
||||
struct alignas(CLS) FreeStack {
|
||||
@@ -695,7 +717,7 @@ private:
|
||||
}
|
||||
IndexType pop_unsafe() { return free[--top]; }
|
||||
bool is_empty() const { return top == 0; }
|
||||
int size() const { return top; }
|
||||
int get_size() const { return top; }
|
||||
} fs;
|
||||
std::size_t reclaim_rot;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user