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


C++ BoundedQueue::push方法代码示例

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

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

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

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

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

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

示例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
}
开发者ID:PeterSommerlad,项目名称:CPlusPlusLecture,代码行数:6,代码来源:bounded_queue_semantic_suite.cpp

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


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