| 242 | |
| 243 | protected: |
| 244 | void Execute(const ExecutionProgress& progress) override { |
| 245 | { |
| 246 | std::unique_lock<std::mutex> lock(_cvm); |
| 247 | // Testing a nullptr send is acceptable. |
| 248 | progress.Send(nullptr, 0); |
| 249 | _cv.wait(lock, [this] { return _test_case_count == 1; }); |
| 250 | } |
| 251 | { |
| 252 | std::unique_lock<std::mutex> lock(_cvm); |
| 253 | progress.Signal(); |
| 254 | _cv.wait(lock, [this] { return _test_case_count == 2; }); |
| 255 | } |
| 256 | // Testing busy looping on send doesn't trigger unexpected empty data |
| 257 | // OnProgress call. |
| 258 | for (size_t i = 0; i < 1000000; i++) { |
| 259 | ProgressData data{0}; |
| 260 | progress.Send(&data, 1); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | void OnProgress(const ProgressData* /* data */, size_t count) override { |
| 265 | Napi::Env env = Env(); |