def test_create(self): pool = CThreadPool(32, start=True) job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1") arg = ctypes.c_int(0) N = 256 for i in range(N): pool.addTask(job, ctypes.byref(arg)) pool.join() self.assertEqual(arg.value, N)
def test_add_task_function(self): pool = CThreadPool(32, start=True) pool.addTaskFunction("testFunction", TEST_LIB, "thread_pool_test_func1") arg = ctypes.c_int(0) task_count = 256 for i in range(task_count): pool.testFunction(ctypes.byref(arg)) pool.join() self.assertEqual(arg.value, task_count)