Fix windows test hang (#17778)
authorxuzhu <xzhu1900@gmail.com>
Tue, 12 Mar 2019 08:43:45 +0000 (01:43 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 12 Mar 2019 08:50:49 +0000 (01:50 -0700)
commitaf2e347164462b9ba93a8ed084f5c6e0f5782c91
treeeedba64906d94dcf42c02cb7fe890e2710a26719
parentf268370b42bc26d4e5d0fd88eb79b44ae162dec5
Fix windows test hang (#17778)

Summary:
This PR resolves two concurrent issues discovered when running the test in windows. Details about the windows test can be found here: https://github.com/pytorch/pytorch/issues/17609

The change covers two fixes:
1. update running_preloaders_ upfront before creating worker thread to prevent underflow.
2. add a lock when updating stop_ to prevent dead lock in condition variable cv_write_.

The fix has been tested on both Windows and Linux. With --gtest_repeat=1000, the tests runs smoothly without issues.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/17778

Differential Revision: D14404910

Pulled By: soumith

fbshipit-source-id: 2fbb8007e4b0bce4613e9a9fd31b8aace1bbfa8d
torch/csrc/api/include/torch/data/datasets/chunk.h