1 // Copyright 2015 The Chromium OS 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 #ifndef LIBBRILLO_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ 6 #define LIBBRILLO_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ 7 8 #include <base/callback.h> 9 #include <base/time/time.h> 10 11 #include <brillo/brillo_export.h> 12 #include <brillo/message_loops/message_loop.h> 13 14 namespace brillo { 15 16 // Run the MessageLoop until the condition passed in |terminate| returns true 17 // or the timeout expires. 18 BRILLO_EXPORT void MessageLoopRunUntil( 19 MessageLoop* loop, 20 base::TimeDelta timeout, 21 base::RepeatingCallback<bool()> terminate); 22 23 // Run the MessageLoop |loop| for up to |iterations| times without blocking. 24 // Return the number of tasks run. 25 BRILLO_EXPORT int MessageLoopRunMaxIterations(MessageLoop* loop, 26 int iterations); 27 28 } // namespace brillo 29 30 #endif // LIBBRILLO_BRILLO_MESSAGE_LOOPS_MESSAGE_LOOP_UTILS_H_ 31