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 "loop.h" 6 7 #include <lib/async-loop/loop.h> 8 9 #include "task_observers.h" 10 11 namespace flutter_runner { 12 13 namespace { 14 LoopEpilogue(async_loop_t *,void *)15static void LoopEpilogue(async_loop_t*, void*) { 16 ExecuteAfterTaskObservers(); 17 } 18 19 constexpr async_loop_config_t kAttachedLoopConfig = { 20 .make_default_for_current_thread = true, 21 .epilogue = &LoopEpilogue, 22 }; 23 24 constexpr async_loop_config_t kDetachedLoopConfig = { 25 .make_default_for_current_thread = false, 26 .epilogue = &LoopEpilogue, 27 }; 28 29 } // namespace 30 MakeObservableLoop(bool attachToThread)31async::Loop* MakeObservableLoop(bool attachToThread) { 32 return new async::Loop( 33 &(attachToThread ? kAttachedLoopConfig : kDetachedLoopConfig)); 34 } 35 36 } // namespace flutter_runner 37