Seastar
High performance C++ framework for concurrent servers
Public Member Functions | List of all members
seastar::gate::holder Class Reference

Detailed Description

Facility to hold a gate opened using RAII.

A gate::holder is usually obtained using gate::hold.

The gate is entered when the gate::holder is constructed, And the gate is left when the gate::holder is destroyed.

Copying the gate::holder reenters the gate to keep an extra reference on it. Moving the gate::holder is supported and has no effect on the gate itself.

Examples
closeable_test.cc.

#include <seastar/core/gate.hh>

Public Member Functions

 holder () noexcept
 
 holder (gate &g)
 
 holder (const holder &x) noexcept
 
 holder (holder &&x) noexcept
 
 ~holder ()
 Destroy a holder and leave the referenced gate.
 
holderoperator= (const holder &x) noexcept
 
holderoperator= (holder &&x) noexcept
 
void release () noexcept
 Leave the held gate.
 

Constructor & Destructor Documentation

◆ holder() [1/4]

seastar::gate::holder::holder ( )
inlinenoexcept

Construct a default holder, referencing no gate. Never throws.

◆ holder() [2/4]

seastar::gate::holder::holder ( gate g)
inlineexplicit

Construct a holder by entering the gate. May throw gate_closed_exception if the gate is already closed.

◆ holder() [3/4]

seastar::gate::holder::holder ( const holder x)
inlinenoexcept

Construct a holder by copying another holder. Copying a holder never throws: The original holder has already entered the gate, so even if later the gate was close()d, the copy of the holder is also allowed to enter too. Note that the fiber waiting for the close(), which until now was waiting for the one holder to leave, will now wait for both copies to leave.

◆ holder() [4/4]

seastar::gate::holder::holder ( holder &&  x)
inlinenoexcept

Construct a holder by moving another holder. The referenced gate is unaffected, and so the move-constructor must never throw.

Member Function Documentation

◆ operator=() [1/2]

holder & seastar::gate::holder::operator= ( const holder x)
inlinenoexcept

Copy-assign another holder. Leave() the current gate before assigning the other one, if they are different. Copying a holder never throws: The original holder has already entered the gate, so even if later the gate was close()d, the copy of the holder is also allowed to enter too. Note that the fiber waiting for the close(), which until now was waiting for the one holder to leave, will now wait for both copies to leave.

◆ operator=() [2/2]

holder & seastar::gate::holder::operator= ( holder &&  x)
inlinenoexcept

Move-assign another holder. The other gate is unaffected, and so the move-assign operator must always succeed. Leave the current gate before assigning the other one.


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