2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-02-13 12:22:36 +00:00

fixes for (un)bounded_channel

This commit is contained in:
Oliver Kowalke
2015-08-04 19:30:31 +02:00
parent dbfde81013
commit 3b6f736a39
4 changed files with 16 additions and 10 deletions

View File

@@ -174,7 +174,7 @@ private:
++count_;
}
value_type & value_pop_() {
value_type value_pop_() {
BOOST_ASSERT( ! is_empty_() );
try {
@@ -188,7 +188,7 @@ private:
not_full_cond_.notify_all();
}
}
return old_head->va;
return std::move( old_head->va);
} catch (...) {
close_();
throw;
@@ -350,7 +350,7 @@ public:
return channel_op_status::closed;
}
std::swap( va, value_pop_() );
va = value_pop_();
return channel_op_status::success;
}
@@ -385,7 +385,7 @@ public:
return channel_op_status::empty;
}
std::swap( va, value_pop_() );
va = value_pop_();
return channel_op_status::success;
}
@@ -411,7 +411,7 @@ public:
return channel_op_status::closed;
}
std::swap( va, value_pop_() );
va = value_pop_();
return channel_op_status::success;
}
};

View File

@@ -128,12 +128,12 @@ private:
tail_ = & new_node->nxt;
}
value_type & value_pop_() {
value_type value_pop_() {
BOOST_ASSERT( ! is_empty_() );
try {
typename node::ptr old_head = pop_head_();
return old_head->va;
return std::move( old_head->va);
} catch (...) {
close_();
throw;
@@ -206,7 +206,7 @@ public:
return channel_op_status::closed;
}
std::swap( va, value_pop_() );
va = value_pop_();
return channel_op_status::success;
}
@@ -241,7 +241,7 @@ public:
return channel_op_status::empty;
}
std::swap( va, value_pop_() );
va = value_pop_();
return channel_op_status::success;
}
@@ -265,7 +265,7 @@ public:
return channel_op_status::closed;
}
std::swap( va, value_pop_() );
va = value_pop_();
return channel_op_status::success;
}
};

View File

@@ -785,13 +785,16 @@ void test_moveable()
BOOST_CHECK( c.is_empty() );
moveable m1( 3), m2;
BOOST_CHECK( m1.state);
BOOST_CHECK_EQUAL( 3, m1.value);
BOOST_CHECK( ! m2.state);
BOOST_CHECK_EQUAL( -1, m2.value);
BOOST_CHECK( boost::fibers::channel_op_status::success == c.push( std::move( m1) ) );
BOOST_CHECK( ! m1.state);
BOOST_CHECK( ! m2.state);
BOOST_CHECK( ! c.is_empty() );
BOOST_CHECK( boost::fibers::channel_op_status::success == c.pop( m2) );
BOOST_CHECK( ! m1.state);
BOOST_CHECK_EQUAL( -1, m1.value);
BOOST_CHECK( m2.state);
BOOST_CHECK_EQUAL( 3, m2.value);
BOOST_CHECK( c.is_empty() );

View File

@@ -344,13 +344,16 @@ void test_moveable()
BOOST_CHECK( c.is_empty() );
moveable m1( 3), m2;
BOOST_CHECK( m1.state);
BOOST_CHECK_EQUAL( 3, m1.value);
BOOST_CHECK( ! m2.state);
BOOST_CHECK_EQUAL( -1, m2.value);
BOOST_CHECK( boost::fibers::channel_op_status::success == c.push( std::move( m1) ) );
BOOST_CHECK( ! m1.state);
BOOST_CHECK( ! m2.state);
BOOST_CHECK( ! c.is_empty() );
BOOST_CHECK( boost::fibers::channel_op_status::success == c.pop( m2) );
BOOST_CHECK( ! m1.state);
BOOST_CHECK_EQUAL( -1, m1.value);
BOOST_CHECK( m2.state);
BOOST_CHECK_EQUAL( 3, m2.value);
BOOST_CHECK( c.is_empty() );