当前位置: 首页>>代码示例>>C++>>正文


C++ BoundedQueue类代码示例

本文整理汇总了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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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;
}
开发者ID:mkaguilera,项目名称:yesquel,代码行数:8,代码来源:test-various.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:8,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:9,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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;
}
开发者ID:mkaguilera,项目名称:yesquel,代码行数:9,代码来源:test-various.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:9,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:9,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:9,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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);
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:9,代码来源:bounded_queue_single_threaded_lock_suite.cpp

示例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());
}
开发者ID:fmorgner,项目名称:cpp-advanced,代码行数:9,代码来源:bounded_queue_single_threaded_lock_suite.cpp


注:本文中的BoundedQueue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。