| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
|---|---|
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "flutter/testing/post_task_sync.h" |
| 6 | |
| 7 | #include "flutter/fml/synchronization/waitable_event.h" |
| 8 | |
| 9 | namespace flutter { |
| 10 | namespace testing { |
| 11 | |
| 12 | void PostTaskSync(const fml::RefPtr<fml::TaskRunner>& task_runner, |
| 13 | const std::function<void()>& function) { |
| 14 | fml::AutoResetWaitableEvent latch; |
| 15 | task_runner->PostTask(task: [&] { |
| 16 | function(); |
| 17 | latch.Signal(); |
| 18 | }); |
| 19 | latch.Wait(); |
| 20 | } |
| 21 | |
| 22 | } // namespace testing |
| 23 | } // namespace flutter |
| 24 |
