trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject [trafficserver] branch master updated: Add IOBufferReader::block_read_view method.
Date Sat, 02 Feb 2019 20:01:50 GMT
This is an automated email from the ASF dual-hosted git repository.

amc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 841697c  Add IOBufferReader::block_read_view method.
841697c is described below

commit 841697c62b0c2fab27c990177b07bd3dc3de999f
Author: Alan M. Carroll <amc@apache.org>
AuthorDate: Wed Jan 23 15:54:59 2019 -0600

    Add IOBufferReader::block_read_view method.
---
 iocore/eventsystem/I_IOBuffer.h | 6 ++++++
 iocore/eventsystem/P_IOBuffer.h | 7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/iocore/eventsystem/I_IOBuffer.h b/iocore/eventsystem/I_IOBuffer.h
index dd1255b..b57d28f 100644
--- a/iocore/eventsystem/I_IOBuffer.h
+++ b/iocore/eventsystem/I_IOBuffer.h
@@ -714,6 +714,12 @@ public:
   */
   int64_t block_read_avail();
 
+  /** Get a view of the data available to read.
+   *
+   * @return A view encompassing currently available readable data.
+   */
+  std::string_view block_read_view();
+
   void skip_empty_blocks();
 
   /**
diff --git a/iocore/eventsystem/P_IOBuffer.h b/iocore/eventsystem/P_IOBuffer.h
index c34af22..d6a4bb4 100644
--- a/iocore/eventsystem/P_IOBuffer.h
+++ b/iocore/eventsystem/P_IOBuffer.h
@@ -621,6 +621,13 @@ IOBufferReader::block_read_avail()
   return (int64_t)(block->end() - (block->start() + start_offset));
 }
 
+inline std::string_view
+IOBufferReader::block_read_view()
+{
+  const char *start = this->start(); // empty blocks are skipped in here.
+  return start ? std::string_view{start, static_cast<size_t>(block->end() - start)}
: std::string_view{};
+}
+
 TS_INLINE int
 IOBufferReader::block_count()
 {


Mime
View raw message