proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
EventBaseHandler.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <
folly/futures/Future.h
>
20
#include <
wangle/channel/Handler.h
>
21
22
namespace
wangle
{
23
24
class
EventBaseHandler
:
public
OutboundBytesToBytesHandler
{
25
public
:
26
folly::Future<folly::Unit>
write
(
27
Context
* ctx,
28
std::unique_ptr<folly::IOBuf> buf)
override
{
29
folly::Future<folly::Unit>
retval;
30
DCHECK(ctx->
getTransport
());
31
DCHECK(ctx->
getTransport
()->getEventBase());
32
ctx->
getTransport
()->getEventBase()->runImmediatelyOrRunInEventBaseThreadAndWait([&](){
33
retval = ctx->
fireWrite
(
std::move
(buf));
34
});
35
return
retval;
36
}
37
38
folly::Future<folly::Unit>
close
(
Context
* ctx)
override
{
39
DCHECK(ctx->
getTransport
());
40
DCHECK(ctx->
getTransport
()->getEventBase());
41
folly::Future<folly::Unit>
retval;
42
ctx->
getTransport
()->getEventBase()->runImmediatelyOrRunInEventBaseThreadAndWait([&](){
43
retval = ctx->
fireClose
();
44
});
45
return
retval;
46
}
47
};
48
49
}
// namespace
wangle::OutboundHandlerContext::fireWrite
virtual folly::Future< folly::Unit > fireWrite(Out msg)=0
folly::gen::move
constexpr detail::Map< Move > move
Definition:
Base-inl.h:2567
wangle::EventBaseHandler
Definition:
EventBaseHandler.h:24
wangle::EventBaseHandler::close
folly::Future< folly::Unit > close(Context *ctx) override
Definition:
EventBaseHandler.h:38
wangle
Definition:
Acceptor.cpp:49
wangle::OutboundHandlerContext< Wout >
wangle::OutboundHandler
Definition:
Handler.h:137
Future.h
folly::Future
Definition:
FiberManagerInternal.h:46
wangle::EventBaseHandler::write
folly::Future< folly::Unit > write(Context *ctx, std::unique_ptr< folly::IOBuf > buf) override
Definition:
EventBaseHandler.h:26
Handler.h
wangle::OutboundHandlerContext::fireClose
virtual folly::Future< folly::Unit > fireClose()=0
wangle::OutboundHandlerContext::getTransport
std::shared_ptr< folly::AsyncTransport > getTransport()
Definition:
HandlerContext.h:102
proxygen
wangle
wangle
channel
EventBaseHandler.h
Generated by
1.8.11