YIHONG-JIN commented on code in PR #11890:
URL: https://github.com/apache/trafficserver/pull/11890#discussion_r1936668534


##########
src/iocore/eventsystem/P_PipeIOBuffer.h:
##########
@@ -0,0 +1,503 @@
+//
+// Created by Yihong Jin on 1/26/25.
+//
+#pragma once
+
+#include "tscore/ink_platform.h"
+#include "tscore/ink_resource.h"
+
+#if TS_USE_LINUX_SPLICE
+extern ClassAllocator<PipeIOBuffer> pipeIOAllocator;
+
+TS_INLINE PipeIOBuffer *
+new_PipeIOBuffer_internal(const char *location, int64_t pipe_capacity)
+{
+  PipeIOBuffer *b = THREAD_ALLOC(pipeIOAllocator, this_thread());
+  b->_location    = location;
+  b->alloc(pipe_capacity);
+  b->water_mark = 0;
+  return b;
+}
+
+TS_INLINE void
+free_PipeIOBuffer(PipeIOBuffer *mio)
+{
+  // static cast to PipeIOBuffer
+  PipeIOBuffer *b = static_cast<PipeIOBuffer *>(mio);
+  b->clear();
+  THREAD_FREE(b, pipeIOAllocator, this_thread());
+}
+
+//////////////////////////////////////////////////////////////////
+//
+//  class PipeIOBufferReader --
+//         inline functions definitions
+//
+//////////////////////////////////////////////////////////////////
+TS_INLINE char *
+PipeIOBufferReader::start()
+{
+  throw std::runtime_error("Not applicable for PipeIOBufferReader");

Review Comment:
   I’m aware of this and have discussed it with Susan. The ultimate solution 
would be to extract a pure abstract class named IOBuffer, making MIOBuffer and 
PipeIOBuffer both derived classes of IOBuffer. This would provide a cleaner 
separation of concerns and eliminate the need for unnecessary overrides. 
However, this would require significant engineering effort, and I may not have 
enough resources to invest in this at the moment.
   
   The reason I explicitly throw errors in empty overridden methods is to 
prevent developers from incorrectly calling MIOBuffer-specific methods on 
inappropriate instances, which could lead to undefined behavior. This ensures 
that such issues are caught early rather than silently causing unintended 
consequences.
   
   I’m open to discussing alternative approaches if there’s a way to improve 
the class design while keeping the effort reasonable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to