proxygen
ByteEventTracker.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
16 
17 namespace proxygen {
18 
19 class TTLBAStats;
20 
30  public:
31  class Callback {
32  public:
33  virtual ~Callback() {}
34  virtual void onPingReplyLatency(int64_t latency) noexcept = 0;
35  virtual void onLastByteEvent(HTTPTransaction* txn,
36  uint64_t offset, bool eomTracked) noexcept = 0;
37  virtual void onDeleteAckEvent() noexcept = 0;
38  };
39 
40  virtual ~ByteEventTracker();
41  explicit ByteEventTracker(Callback* callback): callback_(callback) {}
42 
47  virtual void absorb(ByteEventTracker&& other);
48  void setCallback(Callback* callback) { callback_ = callback; }
49 
54  virtual size_t drainByteEvents();
55 
61  virtual bool processByteEvents(std::shared_ptr<ByteEventTracker> self,
62  uint64_t bytesWritten);
63 
67  void addPingByteEvent(size_t pingSize,
68  TimePoint timestamp,
69  uint64_t bytesScheduled);
70 
72 
73  virtual void addFirstHeaderByteEvent(uint64_t offset, HTTPTransaction* txn);
74 
75  virtual void addLastByteEvent(HTTPTransaction* txn,
76  uint64_t byteNo) noexcept;
77  virtual void addTrackedByteEvent(HTTPTransaction* txn,
78  uint64_t byteNo) noexcept;
79 
81  virtual void addAckByteEvent(uint64_t /*offset*/, HTTPTransaction* /*txn*/) {}
82 
91  virtual uint64_t preSend(bool* /*cork*/, bool* /*eom*/,
92  uint64_t /*bytesWritten*/) {
93  return 0;
94  }
95 
96  virtual void setTTLBAStats(TTLBAStats* /* stats */) {}
97 
98  protected:
99  // byteEvents_ is in the ascending order of ByteEvent::byteOffset_
101 
102  virtual void eomEventProcessed() {}
103 
105 };
106 
107 } // proxygen
void addFirstBodyByteEvent(uint64_t offset, HTTPTransaction *txn)
virtual void addAckByteEvent(uint64_t, HTTPTransaction *)
virtual uint64_t preSend(bool *, bool *, uint64_t)
ByteEventTracker(Callback *callback)
virtual void setTTLBAStats(TTLBAStats *)
virtual void addLastByteEvent(HTTPTransaction *txn, uint64_t byteNo) noexcept
requires E e noexcept(noexcept(s.error(std::move(e))))
void addPingByteEvent(size_t pingSize, TimePoint timestamp, uint64_t bytesScheduled)
virtual void onLastByteEvent(HTTPTransaction *txn, uint64_t offset, bool eomTracked) noexcept=0
virtual void onDeleteAckEvent() noexcept=0
virtual bool processByteEvents(std::shared_ptr< ByteEventTracker > self, uint64_t bytesWritten)
virtual void onPingReplyLatency(int64_t latency) noexcept=0
void setCallback(Callback *callback)
SteadyClock::time_point TimePoint
Definition: Time.h:25
boost::intrusive::list< T, boost::intrusive::member_hook< T, IntrusiveListHook, PtrToMember >, boost::intrusive::constant_time_size< false >> IntrusiveList
Definition: IntrusiveList.h:68
virtual void addFirstHeaderByteEvent(uint64_t offset, HTTPTransaction *txn)
virtual void absorb(ByteEventTracker &&other)
virtual size_t drainByteEvents()
virtual void addTrackedByteEvent(HTTPTransaction *txn, uint64_t byteNo) noexcept
folly::IntrusiveList< ByteEvent,&ByteEvent::listHook > byteEvents_