Skip to content

Commit

Permalink
[EventEngine] Add advice against blocking work in callbacks (#32397)
Browse files Browse the repository at this point in the history
<!--

If you know who should review your pull request, please assign it to
that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the
appropriate
lang label.

-->
  • Loading branch information
drfloob committed Feb 15, 2023
1 parent 77d2475 commit ffe3968
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion include/grpc/event_engine/event_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ namespace grpc_event_engine {
namespace experimental {

////////////////////////////////////////////////////////////////////////////////
/// The EventEngine Interface
///
/// Overview
/// --------
///
/// The EventEngine encapsulates all platform-specific behaviors related to low
/// level network I/O, timers, asynchronous execution, and DNS resolution.
///
Expand All @@ -44,7 +49,8 @@ namespace experimental {
///
/// A default cross-platform EventEngine instance is provided by gRPC.
///
/// LIFESPAN AND OWNERSHIP
/// Lifespan and Ownership
/// ----------------------
///
/// gRPC takes shared ownership of EventEngines via std::shared_ptrs to ensure
/// that the engines remain available until they are no longer needed. Depending
Expand All @@ -71,6 +77,19 @@ namespace experimental {
/// std::unique_ptr<Server> server(builder.BuildAndStart());
/// server->Wait();
///
///
/// Blocking EventEngine Callbacks
/// -----------------------------
///
/// Doing blocking work in EventEngine callbacks is generally not advisable.
/// While gRPC's default EventEngine implementations have some capacity to scale
/// their thread pools to avoid starvation, this is not an instantaneous
/// process. Further, user-provided EventEngines may not be optimized to handle
/// excessive blocking work at all.
///
/// *Best Practice* : Occasional blocking work may be fine, but we do not
/// recommend running a mostly blocking workload in EventEngine threads.
///
////////////////////////////////////////////////////////////////////////////////
class EventEngine : public std::enable_shared_from_this<EventEngine> {
public:
Expand Down

0 comments on commit ffe3968

Please sign in to comment.