本文整理汇总了C++中BoundedQueue::push方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundedQueue::push方法的具体用法?C++ BoundedQueue::push怎么用?C++ BoundedQueue::push使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundedQueue
的用法示例。
在下文中一共展示了BoundedQueue::push方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_push_rvalue_releases_lock
void test_push_rvalue_releases_lock() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<1, 1>> queue { 5 };
reset_counters();
queue.push(1);
ASSERT_EQUAL(1, single_threaded_test_mutex::unlock_count);
}
示例2: test_try_push_for_releases_lock_on_full_queue
void test_try_push_for_releases_lock_on_full_queue() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<1, 0>> queue { 1 };
queue.push(1);
reset_counters();
queue.try_push_for(1, std::chrono::milliseconds { 1 });
ASSERT_EQUAL(2, single_threaded_test_mutex::unlock_count);
}
示例3: test_pop_aquires_lock
void test_pop_aquires_lock() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<1, 1>> queue { 5 };
queue.push(1);
reset_counters();
queue.pop();
ASSERT_EQUAL(1, single_threaded_test_mutex::lock_count);
}
示例4: test_push_lvalue_aquires_lock
void test_push_lvalue_aquires_lock() {
int i { 1 };
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<1, 1>> queue { 5 };
reset_counters();
queue.push(i);
ASSERT_EQUAL(1, single_threaded_test_mutex::lock_count);
}
示例5: test_try_pop_releases_lock
void test_try_pop_releases_lock() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<0, 1>> queue { 5 };
queue.push(1);
int result { };
reset_counters();
queue.try_pop(result);
ASSERT_EQUAL(1, single_threaded_test_mutex::unlock_count);
}
示例6: test_capacity_is_copied_in_ctor
void test_capacity_is_copied_in_ctor() {
//given
BoundedQueue<MemoryOperationCounter> queue{4};
queue.push(MemoryOperationCounter{});
queue.push(MemoryOperationCounter{});
//when
BoundedQueue<MemoryOperationCounter> copy {queue};
copy.push(MemoryOperationCounter{});
copy.push(MemoryOperationCounter{});
//then
ASSERT(copy.full());
}
示例7: test_queue_push_copies_element
void test_queue_push_copies_element() {
BoundedQueue<MemoryOperationCounter> queue { 1 };
MemoryOperationCounter counter { }, expected { 1 , 1, true };
queue.push(counter);
ASSERT_EQUAL(expected, queue.pop()); // pop moves
}
示例8: test_queue_push_moves_element
void test_queue_push_moves_element() {
BoundedQueue<MemoryOperationCounter> queue { 1 };
MemoryOperationCounter counter { }, expected { 2, 0, true };
queue.push(std::move(counter));
ASSERT_EQUAL(expected, queue.pop());
}