From 3cb43d6b9dcee11eac54f3e81931fd084186dbfa Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 11 Nov 2014 08:49:46 -0500 Subject: [PATCH] Make bounded_queue::tail_ a ptr* to simplify appending new nodes. --- include/boost/fiber/bounded_queue.hpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/include/boost/fiber/bounded_queue.hpp b/include/boost/fiber/bounded_queue.hpp index 1e484086..affa325a 100644 --- a/include/boost/fiber/bounded_queue.hpp +++ b/include/boost/fiber/bounded_queue.hpp @@ -93,7 +93,7 @@ private: state_t state_; std::size_t count_; typename node_type::ptr head_; - typename node_type::ptr tail_; + typename node_type::ptr * tail_; mutable mutex mtx_; condition not_empty_cond_; condition not_full_cond_; @@ -171,13 +171,8 @@ private: void push_tail_( typename node_type::ptr new_node) { - if ( is_empty_() ) - head_ = tail_ = new_node; - else - { - tail_->next = new_node; - tail_ = new_node; - } + *tail_ = new_node; + tail_ = &new_node->next; ++count_; } @@ -210,7 +205,7 @@ private: { typename node_type::ptr old_head = head_; head_ = old_head->next; - if ( 0 == head_) tail_ = 0; + if ( 0 == head_) tail_ = &head_; old_head->next = 0; return old_head; } @@ -222,7 +217,7 @@ public: state_( OPEN), count_( 0), head_(), - tail_( head_), + tail_( &head_), mtx_(), not_empty_cond_(), not_full_cond_(), @@ -240,7 +235,7 @@ public: state_( OPEN), count_( 0), head_(), - tail_( head_), + tail_( &head_), mtx_(), not_empty_cond_(), not_full_cond_(),