Exemplo n.º 1
0
TEST(BricksThreadingThreadTest, TaskSync) {
	AutoMonitor<Value> monitor = autonew Value((s32)0);

	AutoPointer<TaskQueue> queue = autonew TaskQueue(1); // 1 thread, serial queue

	for (int i = 0; i < 3; i++)
		queue->PushTask(autonew Task<int>(BricksThreadingThreadTestTaskThread(monitor, i * 100)));

	AutoPointer<Task<int> > task = autonew Task<int>(BricksThreadingThreadTestTaskThread(monitor, 300));
	queue->PushTask(task);

	queue->Start();

	EXPECT_EQ(400, task->Wait());
}
Exemplo n.º 2
0
TEST(BricksThreadingThreadTest, TaskAsync) {
	AutoMonitor<Value> monitor = autonew Value((s32)0);

	AutoPointer<TaskQueue> queue = autonew TaskQueue(3); // 3 threads
	for (int i = 0; i < 10; i++)
		queue->PushTask(autonew Task<int>(BricksThreadingThreadTestTaskThread(monitor)));

	queue->Start();

	queue->Stop(true); // Waits for queue to finish
	EXPECT_EQ(1000, monitor->GetInt32Value());
}