1 // Copyright 2022 The Chromium 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 "quiche/quic/core/io/quic_default_event_loop.h" 6 7 #include <algorithm> 8 #include <memory> 9 #include <vector> 10 11 #include "absl/algorithm/container.h" 12 #include "quiche/quic/core/io/quic_poll_event_loop.h" 13 #include "quiche/common/platform/api/quiche_event_loop.h" 14 15 #ifdef QUICHE_ENABLE_LIBEVENT 16 #include "quiche/quic/bindings/quic_libevent.h" 17 #endif 18 19 namespace quic { 20 GetDefaultEventLoop()21QuicEventLoopFactory* GetDefaultEventLoop() { 22 if (QuicEventLoopFactory* factory = 23 quiche::GetOverrideForDefaultEventLoop()) { 24 return factory; 25 } 26 #ifdef QUICHE_ENABLE_LIBEVENT 27 return QuicLibeventEventLoopFactory::Get(); 28 #else 29 return QuicPollEventLoopFactory::Get(); 30 #endif 31 } 32 GetAllSupportedEventLoops()33std::vector<QuicEventLoopFactory*> GetAllSupportedEventLoops() { 34 std::vector<QuicEventLoopFactory*> loops = {QuicPollEventLoopFactory::Get()}; 35 #ifdef QUICHE_ENABLE_LIBEVENT 36 loops.push_back(QuicLibeventEventLoopFactory::Get()); 37 if (QuicLibeventEventLoopFactory::Get()->GetName() != 38 QuicLibeventEventLoopFactory::GetLevelTriggeredBackendForTests() 39 ->GetName()) { 40 loops.push_back( 41 QuicLibeventEventLoopFactory::GetLevelTriggeredBackendForTests()); 42 } 43 #endif 44 std::vector<QuicEventLoopFactory*> extra = 45 quiche::GetExtraEventLoopImplementations(); 46 loops.insert(loops.end(), extra.begin(), extra.end()); 47 return loops; 48 } 49 50 } // namespace quic 51