summaryrefslogtreecommitdiff
path: root/chromeos/message_loops/message_loop_utils.h
blob: 0af0e361e3d9115955f9f4af3db28ee74906cd87 (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
// Copyright 2015 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_
#define LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_

#include <base/callback.h>
#include <base/time/time.h>

#include <chromeos/chromeos_export.h>
#include <chromeos/message_loops/message_loop.h>

namespace chromeos {

// Run the MessageLoop until the condition passed in |terminate| returns true
// or the timeout expires.
CHROMEOS_EXPORT void MessageLoopRunUntil(
    MessageLoop* loop,
    base::TimeDelta timeout,
    base::Callback<bool()> terminate);

// Run the MessageLoop |loop| for up to |iterations| times without blocking.
// Return the number of tasks run.
CHROMEOS_EXPORT int MessageLoopRunMaxIterations(MessageLoop* loop,
                                                int iterations);

}  // namespace chromeos

#endif  // LIBCHROMEOS_CHROMEOS_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_