xref: /aosp_15_r20/external/cronet/net/third_party/quiche/src/quiche/quic/qbone/bonnet/qbone_tunnel_silo.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright (c) 2020 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 #ifndef QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_SILO_H_
6 #define QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_SILO_H_
7 
8 #include "absl/synchronization/notification.h"
9 #include "quiche/quic/platform/api/quic_thread.h"
10 #include "quiche/quic/qbone/bonnet/qbone_tunnel_interface.h"
11 
12 namespace quic {
13 
14 // QboneTunnelSilo is a thread that initializes and evaluates a QboneTunnel's
15 // event loop.
16 class QboneTunnelSilo : public QuicThread {
17  public:
18   // Does not take ownership of |tunnel|
QboneTunnelSilo(QboneTunnelInterface * tunnel,bool only_setup_tun)19   explicit QboneTunnelSilo(QboneTunnelInterface* tunnel, bool only_setup_tun)
20       : QuicThread("QboneTunnelSilo"),
21         tunnel_(tunnel),
22         only_setup_tun_(only_setup_tun) {}
23 
24   QboneTunnelSilo(const QboneTunnelSilo&) = delete;
25   QboneTunnelSilo& operator=(const QboneTunnelSilo&) = delete;
26 
27   QboneTunnelSilo(QboneTunnelSilo&&) = delete;
28   QboneTunnelSilo& operator=(QboneTunnelSilo&&) = delete;
29 
30   // Terminates the tunnel's event loop. This silo must still be joined.
31   void Quit();
32 
33  protected:
34   void Run() override;
35 
36  private:
37   bool ShouldRun();
38 
39   QboneTunnelInterface* tunnel_;
40 
41   absl::Notification quitting_;
42 
43   const bool only_setup_tun_;
44 };
45 
46 }  // namespace quic
47 
48 #endif  // QUICHE_QUIC_QBONE_BONNET_QBONE_TUNNEL_SILO_H_
49