|
|
@ -5,7 +5,6 @@ |
|
|
|
#include <atomic>
|
|
|
|
#include <new>
|
|
|
|
|
|
|
|
// TODO: rename to task_queue and renamespace to gp::system (filename included)
|
|
|
|
// TODO: noexcept everything
|
|
|
|
|
|
|
|
namespace gp { |
|
|
@ -18,14 +17,14 @@ namespace gp { |
|
|
|
alignas(gp_config::limits::hardware_constructive_interference_size) |
|
|
|
std::atomic<struct node*> next; |
|
|
|
|
|
|
|
node() |
|
|
|
node() noexcept |
|
|
|
{ |
|
|
|
is_locked = false; |
|
|
|
value = nullptr; |
|
|
|
next = nullptr; |
|
|
|
} |
|
|
|
|
|
|
|
node(node&& v) |
|
|
|
node(node&& v) noexcept |
|
|
|
{ |
|
|
|
v.try_acquire(); |
|
|
|
is_locked = false; |
|
|
@ -46,7 +45,7 @@ namespace gp { |
|
|
|
using node_ptr = struct node*; |
|
|
|
using node_ptr_rep = std::atomic<struct node*>; |
|
|
|
|
|
|
|
task_queue() |
|
|
|
task_queue() noexcept |
|
|
|
: start{nullptr} |
|
|
|
, end{nullptr} |
|
|
|
{} |
|
|
@ -55,7 +54,7 @@ namespace gp { |
|
|
|
node_ptr_rep end; |
|
|
|
|
|
|
|
// NODES ARE ACQUIRED ON POP
|
|
|
|
node_ptr try_pop() { |
|
|
|
node_ptr try_pop() k">noexcept { |
|
|
|
auto ptr = start.load(); |
|
|
|
if(!ptr) return nullptr; |
|
|
|
|
|
|
@ -78,7 +77,7 @@ namespace gp { |
|
|
|
|
|
|
|
// ONLY PUSH ACQUIRED NODES,
|
|
|
|
// RELEASE WHEN NO LONGER IN USE
|
|
|
|
bool try_push(node_ptr node) { |
|
|
|
bool try_push(node_ptr node) k">noexcept { |
|
|
|
node->next.store(nullptr); |
|
|
|
auto ed = end.load(); |
|
|
|
if(ed) { |
|
|
|