summaryrefslogtreecommitdiff
path: root/brillo/message_loops/message_loop_utils.h
blob: b7338fd58d8ee586df7f99e7afe961cda7741f05 (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_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_
#define LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_

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

#include <brillo/brillo_export.h>
#include <brillo/message_loops/message_loop.h>

namespace brillo {

// Run the MessageLoop until the condition passed in |terminate| returns true
// or the timeout expires.
BRILLO_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.
BRILLO_EXPORT int MessageLoopRunMaxIterations(MessageLoop* loop,
                                              int iterations);

}  // namespace brillo

#endif  // LIBCHROMEOS_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_