Seastar
High performance C++ framework for concurrent servers
Public Member Functions | Protected Member Functions | Related Functions | List of all members
seastar::named_gate Class Reference
Inheritance diagram for seastar::named_gate:
seastar::gate

Public Member Functions

 named_gate (sstring name) noexcept
 
 named_gate (named_gate &&)=default
 
named_gateoperator= (named_gate &&)=default
 
bool try_enter () noexcept
 
void enter ()
 
void leave () noexcept
 
void check () const
 
future close () noexcept
 
size_t get_count () const noexcept
 Returns a current number of registered in-progress requests.
 
bool is_closed () const noexcept
 Returns whether the gate is closed.
 
holder hold ()
 
std::optional< holdertry_hold () noexcept
 

Protected Member Functions

virtual std::exception_ptr make_closed_exception () const override
 

Related Functions

(Note that these are not member functions.)

template<typename Func >
auto try_with_gate (gate &g, Func &&func) noexcept
 
template<typename Func >
auto with_gate (gate &g, Func &&func)
 

Member Function Documentation

◆ check()

void seastar::gate::check ( ) const
inlineinherited

Potentially stop an in-progress request.

If the gate is already closed, a gate_closed_exception is thrown. By using enter() and leave(), the program can ensure that no further requests are serviced. However, long-running requests may continue to run. The check() method allows such a long operation to voluntarily stop itself after the gate is closed, by making calls to check() in appropriate places. check() with throw an exception and bail out of the long-running code if the gate is closed.

Examples
closeable_test.cc.

◆ close()

future seastar::gate::close ( )
inlinenoexceptinherited

Closes the gate.

Future calls to enter() will fail with an exception, and when all current requests call leave(), the returned future will be made ready.

Examples
closeable_test.cc.

◆ enter()

void seastar::gate::enter ( )
inlineinherited

Registers an in-progress request.

If the gate is not closed, the request is registered. Otherwise, a gate_closed_exception is thrown.

Examples
closeable_test.cc.

◆ hold()

holder seastar::gate::hold ( )
inlineinherited

Get a RAII-based gate::holder object that enter()s the gate when constructed and leave()s it when destroyed.

Examples
closeable_test.cc.

◆ leave()

void seastar::gate::leave ( )
inlinenoexceptinherited

Unregisters an in-progress request.

If the gate is closed, and there are no more in-progress requests, the _stopped promise will be fulfilled.

Examples
closeable_test.cc.

◆ make_closed_exception()

virtual std::exception_ptr seastar::named_gate::make_closed_exception ( ) const
inlineoverrideprotectedvirtual

Reimplemented from seastar::gate.

◆ try_enter()

bool seastar::gate::try_enter ( )
inlinenoexceptinherited

Tries to register an in-progress request.

If the gate is not closed, the request is registered and the function returns true, Otherwise the function just returns false and has no other effect.

◆ try_hold()

std::optional< holder > seastar::gate::try_hold ( )
inlinenoexceptinherited

Try getting an optional RAII-based gate::holder object that enter()s the gate when constructed and leave()s it when destroyed. Returns std::nullopt iff the gate is closed.

Examples
closeable_test.cc.

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