mirror of https://github.com/grpc/grpc.git
[EventEngine] Modify iomgr to allow creation of posix event engine listeners and server side endpoints (#31928)
* [WIP] EventEngine iomgr endpoint shims * [WIP] EventEngine::Endpoint iomgr shims for the PosixEventEngine * Util functions to help with posix engine listener implementation * sanity * update comments in posix_engine_listener_utils.h * review comments * iwyu * revert prev commit * iwyu * update build * update * regenerate projects * regenerate projects * minor fixes * update BUILD * sanity * update build * regenerate projects * fix unused parameter * sanity * update * sanity * regenerate_projects * remove unused variable * start * update * regenerate_projects * sanity * update * fixes * update * regenerate_projects * update * fix sanity and msan failure * more fixes * build failure * update * fix * sanity * fixes * update * regenerate projects * fix sanity * review comments * An EventEngine subclass to be implemented by all posix based event engines * sanity * comments * update * review comments * re-word * fix * update * review comments * regenerate projects * syntax fix * add lock free event benchmark * releasable mutex lock * fix build isue * update * start * regenerate projects * update * fix * windows build * update * windows portability issue * update * update * update * update * format * update * update * start * Update tcp server interface to move on_accept_cb to create method * update * start * update * update * update * update * update * update * update * update * sanity * update * update * update * windows build * fix msan * fix sanity * regenerate projects * update * iwyu * Fix resolved address length related bugs in tcp_socket_utils and listener_utils * iwyu * cleanup * cleanup src/core/lib/event_engine/tcp_socket_utils.cc * iwyu * fix * regenerate projects * fix sanity * re-write endpoint shim * more re-write * cleanup * update * regenerate projects * review comments * build issue * more build issue fixes plus adding event_engine_trace * even more build issue fixes * iwyu * add static_cast * fix sanity * update * update * sanity * fix * Fix * Review comments * fix * iwyu * fix build issue Co-authored-by: AJ Heller <hork@google.com>pull/32285/head
parent
4a64142be5
commit
fa5a6c42a6
42 changed files with 590 additions and 62 deletions
@ -0,0 +1,62 @@ |
|||||||
|
// Copyright 2021 gRPC Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/event_engine_shims/closure.h" |
||||||
|
|
||||||
|
#include "absl/functional/any_invocable.h" |
||||||
|
#include "absl/status/status.h" |
||||||
|
|
||||||
|
#include <grpc/event_engine/event_engine.h> |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/closure.h" |
||||||
|
#include "src/core/lib/iomgr/exec_ctx.h" |
||||||
|
#include "src/core/lib/transport/error_utils.h" |
||||||
|
|
||||||
|
namespace grpc_event_engine { |
||||||
|
namespace experimental { |
||||||
|
|
||||||
|
void RunEventEngineClosure(grpc_closure* closure, grpc_error_handle error) { |
||||||
|
if (closure == nullptr) { |
||||||
|
return; |
||||||
|
} |
||||||
|
grpc_core::ApplicationCallbackExecCtx app_ctx; |
||||||
|
grpc_core::ExecCtx exec_ctx; |
||||||
|
#ifndef NDEBUG |
||||||
|
closure->scheduled = false; |
||||||
|
if (grpc_trace_closure.enabled()) { |
||||||
|
gpr_log(GPR_DEBUG, |
||||||
|
"EventEngine: running closure %p: created [%s:%d]: %s [%s:%d]", |
||||||
|
closure, closure->file_created, closure->line_created, |
||||||
|
closure->run ? "run" : "scheduled", closure->file_initiated, |
||||||
|
closure->line_initiated); |
||||||
|
} |
||||||
|
#endif |
||||||
|
closure->cb(closure->cb_arg, error); |
||||||
|
#ifndef NDEBUG |
||||||
|
if (grpc_trace_closure.enabled()) { |
||||||
|
gpr_log(GPR_DEBUG, "EventEngine: closure %p finished", closure); |
||||||
|
} |
||||||
|
#endif |
||||||
|
} |
||||||
|
|
||||||
|
absl::AnyInvocable<void(absl::Status)> GrpcClosureToStatusCallback( |
||||||
|
grpc_closure* closure) { |
||||||
|
return [closure](absl::Status status) { |
||||||
|
RunEventEngineClosure(closure, absl_status_to_grpc_error(status)); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
} // namespace experimental
|
||||||
|
} // namespace grpc_event_engine
|
@ -0,0 +1,39 @@ |
|||||||
|
// Copyright 2022 gRPC Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
#ifndef GRPC_SRC_CORE_LIB_IOMGR_EVENT_ENGINE_SHIMS_CLOSURE_H |
||||||
|
#define GRPC_SRC_CORE_LIB_IOMGR_EVENT_ENGINE_SHIMS_CLOSURE_H |
||||||
|
|
||||||
|
#include <grpc/support/port_platform.h> |
||||||
|
|
||||||
|
#include "absl/functional/any_invocable.h" |
||||||
|
|
||||||
|
#include <grpc/event_engine/event_engine.h> |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/closure.h" |
||||||
|
#include "src/core/lib/iomgr/error.h" |
||||||
|
|
||||||
|
namespace grpc_event_engine { |
||||||
|
namespace experimental { |
||||||
|
|
||||||
|
/// Runs a grpc_closure inline with the specified error handle.
|
||||||
|
void RunEventEngineClosure(grpc_closure* closure, grpc_error_handle error); |
||||||
|
|
||||||
|
/// Creates a callback that takes an error status argument.
|
||||||
|
absl::AnyInvocable<void(absl::Status)> GrpcClosureToStatusCallback( |
||||||
|
grpc_closure* closure); |
||||||
|
|
||||||
|
} // namespace experimental
|
||||||
|
} // namespace grpc_event_engine
|
||||||
|
|
||||||
|
#endif // GRPC_SRC_CORE_LIB_IOMGR_EVENT_ENGINE_SHIMS_CLOSURE_H
|
Loading…
Reference in new issue