Skip to content
Snippets Groups Projects
  • Mark Michelson's avatar
    8055d080
    Fix failing threadpool_auto_increment test. · 8055d080
    Mark Michelson authored
    The threadpool_auto_increment test fails infrequently for a couple of
    reasons
    * The threadpool listener was notified of fewer tasks being pushed than
      were actually pushed
    * The "was_empty" flag was set to an unexpected value.
    
    The problem is that the test pushes three tasks into the threadpool.
    Test expects the threadpool to essentially gather those three tasks, and
    then distribute those to the threadpool threads. It also expects that as
    the tasks are pushed in, the threadpool listener is alerted immediately
    that the tasks have been pushed. In reality, a task can be distributed
    to the threadpool threads quicker than expected, meaning that the
    threadpool has already emptied by the time each subsequent task is
    pushed. In addition, the internal threadpool queue can be delayed so
    that the threadpool listener is not alerted that a task has been pushed
    even after the task has been executed.
    
    From the test's point of view, there's no way to be able to predict
    exactly the order that task execution/listener notifications will occur,
    and there is no way to know which listener notifications will indicate
    that the threadpool was previously empty.
    
    For this reason, the test has been updated to only check the things it
    can check. It ensures that all tasks get executed, that the threads go
    idle after the tasks are executed, and that the listener is told the
    proper number of tasks that were pushed.
    
    Change-Id: I7673120d74adad64ae6894594a606e102d9a1f2c
    8055d080
    History
    Fix failing threadpool_auto_increment test.
    Mark Michelson authored
    The threadpool_auto_increment test fails infrequently for a couple of
    reasons
    * The threadpool listener was notified of fewer tasks being pushed than
      were actually pushed
    * The "was_empty" flag was set to an unexpected value.
    
    The problem is that the test pushes three tasks into the threadpool.
    Test expects the threadpool to essentially gather those three tasks, and
    then distribute those to the threadpool threads. It also expects that as
    the tasks are pushed in, the threadpool listener is alerted immediately
    that the tasks have been pushed. In reality, a task can be distributed
    to the threadpool threads quicker than expected, meaning that the
    threadpool has already emptied by the time each subsequent task is
    pushed. In addition, the internal threadpool queue can be delayed so
    that the threadpool listener is not alerted that a task has been pushed
    even after the task has been executed.
    
    From the test's point of view, there's no way to be able to predict
    exactly the order that task execution/listener notifications will occur,
    and there is no way to know which listener notifications will indicate
    that the threadpool was previously empty.
    
    For this reason, the test has been updated to only check the things it
    can check. It ensures that all tasks get executed, that the threads go
    idle after the tasks are executed, and that the listener is told the
    proper number of tasks that were pushed.
    
    Change-Id: I7673120d74adad64ae6894594a606e102d9a1f2c
test_threadpool.c 41.30 KiB