本文整理汇总了C++中BoundedQueue类的典型用法代码示例。如果您正苦于以下问题:C++ BoundedQueue类的具体用法?C++ BoundedQueue怎么用?C++ BoundedQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BoundedQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_swap_aquires_both_locks
void test_swap_aquires_both_locks() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<>> queue { 5 }, other { 4 };
reset_counters();
queue.swap(other);
ASSERT_EQUAL(2, single_threaded_test_mutex::lock_count + single_threaded_test_mutex::try_lock_count);
}
示例2: test_full_aquires_lock
void test_full_aquires_lock() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<0, 0>> queue { 5 };
reset_counters();
queue.full();
ASSERT_EQUAL(1, single_threaded_test_mutex::lock_count);
}
示例3: test_push_rvalue_aquires_lock
void test_push_rvalue_aquires_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::lock_count);
}
示例4: test_swap_aquires_tries_multiple_times_to_try_lock
void test_swap_aquires_tries_multiple_times_to_try_lock() {
BoundedQueue<int, single_threaded_count_down_mutex<3>, single_threaded_condition_variable<>> queue { 5 }, other { 4 };
reset_counters();
queue.swap(other);
ASSERT_EQUAL(4, single_threaded_test_mutex::try_lock_count);
}
示例5: test_try_push_rvalue_releases_lock
void test_try_push_rvalue_releases_lock() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<0, 1>> queue { 5 };
reset_counters();
queue.try_push(1);
ASSERT_EQUAL(1, single_threaded_test_mutex::unlock_count);
}
示例6: test6_enqueuer
OSTHREAD_FUNC test6_enqueuer(void *data){
BoundedQueue<int> *queue = (BoundedQueue<int> *) data;
int i;
for (i=0; i < TEST6_NOPS; ++i){
queue->enqueue(i);
}
return 0;
}
示例7: test_size_releases_lock
void test_size_releases_lock() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<>> queue { 5 };
reset_counters();
queue.size();
ASSERT_EQUAL(1, single_threaded_test_mutex::unlock_count);
}
示例8: test_swap_releases_two_locks
void test_swap_releases_two_locks() {
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<>> queue { 5 }, other { 4 };
reset_counters();
queue.swap(other);
ASSERT_EQUAL(2, single_threaded_test_mutex::unlock_count);
}
示例9: test_pop_releases_lock
void test_pop_releases_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::unlock_count);
}
示例10: test6_dequeuer
OSTHREAD_FUNC test6_dequeuer(void *data){
BoundedQueue<int> *queue = (BoundedQueue<int> *) data;
int i, item;
for (i=0; i < TEST6_NOPS; ++i){
item = queue->dequeue();
assert(item==i);
}
return 0;
}
示例11: 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);
}
示例12: test_try_push_for_aquires_lock_on_empty_queue
void test_try_push_for_aquires_lock_on_empty_queue() {
int i { 1 };
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<1, 1>> queue { 5 };
reset_counters();
queue.try_push_for(i, std::chrono::milliseconds { 1 });
ASSERT_EQUAL(1, single_threaded_test_mutex::lock_count);
}
示例13: test_try_pop_for_releases_lock_on_empty_queue
void test_try_pop_for_releases_lock_on_empty_queue() {
int result { };
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<1, 0>> queue { 5 };
reset_counters();
queue.try_pop_for(result, std::chrono::milliseconds { 1 });
ASSERT_EQUAL(2, single_threaded_test_mutex::unlock_count);
}
示例14: test_try_push_lvalue_aquires_lock
void test_try_push_lvalue_aquires_lock() {
int i { 1 };
BoundedQueue<int, single_threaded_test_mutex, single_threaded_condition_variable<0, 1>> queue { 5 };
reset_counters();
queue.try_push(i);
ASSERT_EQUAL(1, single_threaded_test_mutex::lock_count);
}
示例15: test_swap_successful_after_delayed_lock
void test_swap_successful_after_delayed_lock() {
BoundedQueue<int, single_threaded_count_down_mutex<1>, single_threaded_condition_variable<1, 1>> queue { 5 }, other { 4 };
other.push(17);
reset_counters();
queue.swap(other);
ASSERT_EQUAL(17, queue.pop());
}