proxygen
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 
25  public:
27  Context* ctx,
28  std::unique_ptr<folly::IOBuf> buf) override {
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 
39  DCHECK(ctx->getTransport());
40  DCHECK(ctx->getTransport()->getEventBase());
42  ctx->getTransport()->getEventBase()->runImmediatelyOrRunInEventBaseThreadAndWait([&](){
43  retval = ctx->fireClose();
44  });
45  return retval;
46  }
47 };
48 
49 } // namespace
virtual folly::Future< folly::Unit > fireWrite(Out msg)=0
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::Future< folly::Unit > close(Context *ctx) override
folly::Future< folly::Unit > write(Context *ctx, std::unique_ptr< folly::IOBuf > buf) override
virtual folly::Future< folly::Unit > fireClose()=0
std::shared_ptr< folly::AsyncTransport > getTransport()