summaryrefslogtreecommitdiffstats
path: root/ui/ozone/platform/drm/gpu/proxy_helpers.cc
blob: 556280d9b625fd59bb0c5fa6d54dc0f17c82b7a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/ozone/platform/drm/gpu/proxy_helpers.h"

#include "base/synchronization/waitable_event.h"

namespace ui {

namespace {

void OnRunPostedTaskAndSignal(const base::Closure& callback,
                              base::WaitableEvent* wait) {
  callback.Run();
  wait->Signal();
}

}  // namespace

void PostSyncTask(
    const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
    const base::Closure& callback) {
  base::WaitableEvent wait(false, false);
  bool success = task_runner->PostTask(
      FROM_HERE, base::Bind(OnRunPostedTaskAndSignal, callback, &wait));
  if (success)
    wait.Wait();
}

}  // namespace ui