TBB executor for GAPI: fix race consition in Async test
authorAnton Potapov <anton.potapov@intel.com>
Tue, 1 Dec 2020 08:12:36 +0000 (11:12 +0300)
committerAnton Potapov <anton.potapov@intel.com>
Tue, 1 Dec 2020 08:12:36 +0000 (11:12 +0300)
commiteb6d8e6af233e0c021bfae4e04f36b2b844157a8
treec5cf20e4683f44b10371644e9a7e5186e71fbda0
parente726ff3296b9e382371a778ad807d37a2e49b979
TBB executor for GAPI: fix race consition in Async test

The test has race condition, which is addressed by the patch.

The race is next:

    Master thread is calling execute (effectively blocked, waiting for
callback to be called)
    "Async" thread picks up the callback
    Call the callback
    Then sets the variables in test
    After call back is called, master thread is unblocked and may check
the variables (set in point 4 by the "async" thread) earlier then they
actually changed

Changes:

    callback should be called as the last step (after flag variables are
    set), as it effectively unblock the master thread

fixes #18974
modules/gapi/test/executor/gtbbexecutor_internal_tests.cpp