proxygen
wangle::ContextImpl< H > Class Template Reference

#include <HandlerContext-inl.h>

Inheritance diagram for wangle::ContextImpl< H >:
wangle::HandlerContext< H::rout, H::wout > wangle::InboundLink< H::rin > wangle::OutboundLink< H::win > wangle::ContextImplBase< H, HandlerContext< H::rout, H::wout > > wangle::PipelineContext

Public Types

typedef H::rin Rin
 
typedef H::rout Rout
 
typedef H::win Win
 
typedef H::wout Wout
 

Public Member Functions

 ContextImpl (std::weak_ptr< PipelineBase > pipeline, std::shared_ptr< H > handler)
 
 ContextImpl ()
 
 ~ContextImpl () override=default
 
void fireRead (Rout msg) override
 
void fireReadEOF () override
 
void fireReadException (folly::exception_wrapper e) override
 
void fireTransportActive () override
 
void fireTransportInactive () override
 
folly::Future< folly::UnitfireWrite (Wout msg) override
 
folly::Future< folly::UnitfireWriteException (folly::exception_wrapper e) override
 
folly::Future< folly::UnitfireClose () override
 
PipelineBasegetPipeline () override
 
std::shared_ptr< PipelineBasegetPipelineShared () override
 
void setWriteFlags (folly::WriteFlags flags) override
 
folly::WriteFlags getWriteFlags () override
 
void setReadBufferSettings (uint64_t minAvailable, uint64_t allocationSize) override
 
std::pair< uint64_t, uint64_tgetReadBufferSettings () override
 
void read (Rin msg) override
 
void readEOF () override
 
void readException (folly::exception_wrapper e) override
 
void transportActive () override
 
void transportInactive () override
 
folly::Future< folly::Unitwrite (Win msg) override
 
folly::Future< folly::UnitwriteException (folly::exception_wrapper e) override
 
folly::Future< folly::Unitclose () override
 
- Public Member Functions inherited from wangle::HandlerContext< H::rout, H::wout >
virtual ~HandlerContext ()=default
 
std::shared_ptr< folly::AsyncTransportgetTransport ()
 
- Public Member Functions inherited from wangle::ContextImplBase< H, HandlerContext< H::rout, H::wout > >
 ~ContextImplBase () override=default
 
H * getHandler ()
 
void initialize (std::weak_ptr< PipelineBase > pipeline, std::shared_ptr< H > handler)
 
void attachPipeline () override
 
void detachPipeline () override
 
void setNextIn (PipelineContext *ctx) override
 
void setNextOut (PipelineContext *ctx) override
 
HandlerDir getDirection () override
 
- Public Member Functions inherited from wangle::PipelineContext
virtual ~PipelineContext ()=default
 
template<class H , class HandlerContext >
void attachContext (H *handler, HandlerContext *ctx)
 
template<class H , class HandlerContext >
void detachContext (H *handler, HandlerContext *)
 

Static Public Attributes

static const HandlerDir dir = HandlerDir::BOTH
 

Additional Inherited Members

- Protected Attributes inherited from wangle::ContextImplBase< H, HandlerContext< H::rout, H::wout > >
HandlerContext< H::rout, H::wout > * impl_
 
std::weak_ptr< PipelineBasepipelineWeak_
 
PipelineBasepipelineRaw_
 
std::shared_ptr< H > handler_
 
InboundLink< typename H::rout > * nextIn_
 
OutboundLink< typename H::wout > * nextOut_
 

Detailed Description

template<class H>
class wangle::ContextImpl< H >

Definition at line 151 of file HandlerContext-inl.h.

Member Typedef Documentation

template<class H >
typedef H::rin wangle::ContextImpl< H >::Rin

Definition at line 159 of file HandlerContext-inl.h.

template<class H >
typedef H::rout wangle::ContextImpl< H >::Rout

Definition at line 160 of file HandlerContext-inl.h.

template<class H >
typedef H::win wangle::ContextImpl< H >::Win

Definition at line 161 of file HandlerContext-inl.h.

template<class H >
typedef H::wout wangle::ContextImpl< H >::Wout

Definition at line 162 of file HandlerContext-inl.h.

Constructor & Destructor Documentation

template<class H >
wangle::ContextImpl< H >::ContextImpl ( std::weak_ptr< PipelineBase pipeline,
std::shared_ptr< H >  handler 
)
inlineexplicit

Definition at line 165 of file HandlerContext-inl.h.

References folly::gen::move.

167  {
168  this->impl_ = this;
169  this->initialize(pipeline, std::move(handler));
170  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void handler(int, siginfo_t *, void *)
void initialize(std::weak_ptr< PipelineBase > pipeline, std::shared_ptr< H > handler)
template<class H >
wangle::ContextImpl< H >::ContextImpl ( )
inline

Definition at line 173 of file HandlerContext-inl.h.

173  {
174  this->impl_ = this;
175  }
template<class H >
wangle::ContextImpl< H >::~ContextImpl ( )
overridedefault

Member Function Documentation

template<class H >
folly::Future<folly::Unit> wangle::ContextImpl< H >::close ( )
inlineoverridevirtual

Implements wangle::OutboundLink< H::win >.

Definition at line 316 of file HandlerContext-inl.h.

References folly::gen::guard().

316  {
317  auto guard = this->pipelineWeak_.lock();
318  return this->handler_->close(this);
319  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
folly::Future<folly::Unit> wangle::ContextImpl< H >::fireClose ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 242 of file HandlerContext-inl.h.

References folly::gen::guard(), folly::makeFuture(), and folly::WARNING.

242  {
243  auto guard = this->pipelineWeak_.lock();
244  if (this->nextOut_) {
245  return this->nextOut_->close();
246  } else {
247  LOG(WARNING) << "close reached end of pipeline";
248  return folly::makeFuture();
249  }
250  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
template<class H >
void wangle::ContextImpl< H >::fireRead ( Rout  msg)
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 180 of file HandlerContext-inl.h.

References folly::gen::guard(), and folly::WARNING.

180  {
181  auto guard = this->pipelineWeak_.lock();
182  if (this->nextIn_) {
183  this->nextIn_->read(std::forward<Rout>(msg));
184  } else {
185  LOG(WARNING) << "read reached end of pipeline";
186  }
187  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::fireReadEOF ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 189 of file HandlerContext-inl.h.

References folly::gen::guard(), and folly::WARNING.

189  {
190  auto guard = this->pipelineWeak_.lock();
191  if (this->nextIn_) {
192  this->nextIn_->readEOF();
193  } else {
194  LOG(WARNING) << "readEOF reached end of pipeline";
195  }
196  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::fireReadException ( folly::exception_wrapper  e)
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 198 of file HandlerContext-inl.h.

References folly::gen::guard(), folly::gen::move, and folly::WARNING.

198  {
199  auto guard = this->pipelineWeak_.lock();
200  if (this->nextIn_) {
201  this->nextIn_->readException(std::move(e));
202  } else {
203  LOG(WARNING) << "readException reached end of pipeline";
204  }
205  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::fireTransportActive ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 207 of file HandlerContext-inl.h.

References folly::gen::guard().

207  {
208  auto guard = this->pipelineWeak_.lock();
209  if (this->nextIn_) {
210  this->nextIn_->transportActive();
211  }
212  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::fireTransportInactive ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 214 of file HandlerContext-inl.h.

References folly::gen::guard().

214  {
215  auto guard = this->pipelineWeak_.lock();
216  if (this->nextIn_) {
217  this->nextIn_->transportInactive();
218  }
219  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
folly::Future<folly::Unit> wangle::ContextImpl< H >::fireWrite ( Wout  msg)
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 221 of file HandlerContext-inl.h.

References folly::gen::guard(), folly::makeFuture(), and folly::WARNING.

221  {
222  auto guard = this->pipelineWeak_.lock();
223  if (this->nextOut_) {
224  return this->nextOut_->write(std::forward<Wout>(msg));
225  } else {
226  LOG(WARNING) << "write reached end of pipeline";
227  return folly::makeFuture();
228  }
229  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
template<class H >
folly::Future<folly::Unit> wangle::ContextImpl< H >::fireWriteException ( folly::exception_wrapper  e)
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 231 of file HandlerContext-inl.h.

References folly::gen::guard(), folly::makeFuture(), folly::gen::move, and folly::WARNING.

232  {
233  auto guard = this->pipelineWeak_.lock();
234  if (this->nextOut_) {
235  return this->nextOut_->writeException(std::move(e));
236  } else {
237  LOG(WARNING) << "close reached end of pipeline";
238  return folly::makeFuture();
239  }
240  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition: Future-inl.h:1310
template<class H >
PipelineBase* wangle::ContextImpl< H >::getPipeline ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 252 of file HandlerContext-inl.h.

252  {
253  return this->pipelineRaw_;
254  }
template<class H >
std::shared_ptr<PipelineBase> wangle::ContextImpl< H >::getPipelineShared ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 256 of file HandlerContext-inl.h.

256  {
257  return this->pipelineWeak_.lock();
258  }
template<class H >
std::pair<uint64_t, uint64_t> wangle::ContextImpl< H >::getReadBufferSettings ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 274 of file HandlerContext-inl.h.

274  {
275  return this->pipelineRaw_->getReadBufferSettings();
276  }
std::pair< uint64_t, uint64_t > getReadBufferSettings()
Definition: Pipeline.cpp:37
template<class H >
folly::WriteFlags wangle::ContextImpl< H >::getWriteFlags ( )
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 264 of file HandlerContext-inl.h.

264  {
265  return this->pipelineRaw_->getWriteFlags();
266  }
folly::WriteFlags getWriteFlags()
Definition: Pipeline.cpp:27
template<class H >
void wangle::ContextImpl< H >::read ( Rin  msg)
inlineoverridevirtual

Implements wangle::InboundLink< H::rin >.

Definition at line 279 of file HandlerContext-inl.h.

References folly::gen::guard().

279  {
280  auto guard = this->pipelineWeak_.lock();
281  this->handler_->read(this, std::forward<Rin>(msg));
282  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::readEOF ( )
inlineoverridevirtual

Implements wangle::InboundLink< H::rin >.

Definition at line 284 of file HandlerContext-inl.h.

References folly::gen::guard().

284  {
285  auto guard = this->pipelineWeak_.lock();
286  this->handler_->readEOF(this);
287  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::readException ( folly::exception_wrapper  e)
inlineoverridevirtual

Implements wangle::InboundLink< H::rin >.

Definition at line 289 of file HandlerContext-inl.h.

References folly::gen::guard(), and folly::gen::move.

289  {
290  auto guard = this->pipelineWeak_.lock();
291  this->handler_->readException(this, std::move(e));
292  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::setReadBufferSettings ( uint64_t  minAvailable,
uint64_t  allocationSize 
)
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 268 of file HandlerContext-inl.h.

270  {
271  this->pipelineRaw_->setReadBufferSettings(minAvailable, allocationSize);
272  }
void setReadBufferSettings(uint64_t minAvailable, uint64_t allocationSize)
Definition: Pipeline.cpp:31
template<class H >
void wangle::ContextImpl< H >::setWriteFlags ( folly::WriteFlags  flags)
inlineoverridevirtual

Implements wangle::HandlerContext< H::rout, H::wout >.

Definition at line 260 of file HandlerContext-inl.h.

260  {
262  }
flags
Definition: http_parser.h:127
void setWriteFlags(folly::WriteFlags flags)
Definition: Pipeline.cpp:23
template<class H >
void wangle::ContextImpl< H >::transportActive ( )
inlineoverridevirtual

Implements wangle::InboundLink< H::rin >.

Definition at line 294 of file HandlerContext-inl.h.

References folly::gen::guard().

294  {
295  auto guard = this->pipelineWeak_.lock();
296  this->handler_->transportActive(this);
297  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
void wangle::ContextImpl< H >::transportInactive ( )
inlineoverridevirtual

Implements wangle::InboundLink< H::rin >.

Definition at line 299 of file HandlerContext-inl.h.

References folly::gen::guard().

299  {
300  auto guard = this->pipelineWeak_.lock();
301  this->handler_->transportInactive(this);
302  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
folly::Future<folly::Unit> wangle::ContextImpl< H >::write ( Win  msg)
inlineoverridevirtual

Implements wangle::OutboundLink< H::win >.

Definition at line 305 of file HandlerContext-inl.h.

References folly::gen::guard().

305  {
306  auto guard = this->pipelineWeak_.lock();
307  return this->handler_->write(this, std::forward<Win>(msg));
308  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class H >
folly::Future<folly::Unit> wangle::ContextImpl< H >::writeException ( folly::exception_wrapper  e)
inlineoverridevirtual

Implements wangle::OutboundLink< H::win >.

Definition at line 310 of file HandlerContext-inl.h.

References folly::gen::guard(), and folly::gen::move.

311  {
312  auto guard = this->pipelineWeak_.lock();
313  return this->handler_->writeException(this, std::move(e));
314  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840

Member Data Documentation

template<class H >
const HandlerDir wangle::ContextImpl< H >::dir = HandlerDir::BOTH
static

Definition at line 163 of file HandlerContext-inl.h.


The documentation for this class was generated from the following file: