Problem: If a test case has these conditions below
1) leverage FactoryTaskManager with multiple tasks and test_ui
2) there is a limited resource should be owned by one task in a time
3) A FactoryTask bind a key to test_ui for calling pass() or fail()
then it is possible to happen that a task later can't acquire this limited resource successfully then test case will be failed. This is because the limited resource are competed by two parallel tasks in different threads.
Even worse that, if a factory task be run on the thread of test_ui then it might block this thread to deal with next event in the queue (EventClient). ex: task run in a loop and wait for test_ui thread's notification.
Detail:
a. Here I assume that FactoryTaskManager should run tasks sequentially (and maybe in one single thread) so the designer who leverages it don't need to take care resource contention. Designer can treat all tasks can be done one by one and not in parallel.
b. Normally if you run FactoryTaskManager in a test case then the assumption above is correct.
c. But if you run FactoryTaskManager and depend on BindKey of test_ui to trigger TaskManager.Pass/Fail() then it turns out that next task will be run on thread of test_ui not original one thread of creating FactoryTaskManager
Comment 1 by pnangunoori@chromium.org
, Jul 13 2017