JH-Toolkit v1.4.1
An engineering-oriented C++20 toolkit with duck-typed concepts, static design, async coroutines, and semantic containers — header-only, RTTI-free, and concurrency-friendly.
Loading...
Searching...
No Matches
jh::async::slot_hub Class Referencefinal

Synchronization domain managing timed mutex acquisition and binding exactly one slot. More...

#include <jh/asynchronous/slot.h>

Public Member Functions

 slot_hub (std::chrono::milliseconds t)
 Construct a slot_hub with a timeout.
void bind_slot (slot &s) noexcept
 Bind a slot coroutine to this hub.
template<typename T>
listener< T > make_listener () noexcept
 Create a new listener bound to this slot_hub.

Friends

template<typename T>
class listener
 Grants listener<T> access to internal slot.

Detailed Description

Synchronization domain managing timed mutex acquisition and binding exactly one slot.

A slot_hub is not just a synchronizer; it's also a factory for listeners and a creator of topologies. It allows slots and listeners to be constructed separately but bound to the same scope.

Positioning

A slot_hub defines:

  • The strong-synchronization domain using a std::timed_mutex.
  • The timeout policy for event delivery.
  • The one-to-one binding to a single slot.

Responsibilities

  • Atomically: write inbox → resume slot (under the same lock).
  • Reject event submissions that exceed the timeout window.
  • Create listeners via make_listener.
Note
The slot_hub performs no buffering. Every event is either: fully delivered (value written + slot resumed) or completely rejected.
Warning
Only one slot may be bound to a hub. Binding multiple slots is wrong.

Constructor & Destructor Documentation

◆ slot_hub()

jh::async::slot_hub::slot_hub ( std::chrono::milliseconds t)
inlineexplicit

Construct a slot_hub with a timeout.

Initializes the internal timed mutex and sets the delivery timeout window.

Parameters
tTimeout duration for acquiring the lock during emit.

Member Function Documentation

◆ bind_slot()

void jh::async::slot_hub::bind_slot ( slot & s)
inlinenoexcept

Bind a slot coroutine to this hub.

Associates a single slot coroutine with this synchronization domain.

Parameters
sReference to the slot to bind.

◆ make_listener()

template<typename T>
listener< T > jh::async::slot_hub::make_listener ( )
inlinenoexcept

Create a new listener bound to this slot_hub.

The listener will share the hub's timeout and mutex context.

Template Parameters
TType of payload the listener will receive.
Returns
A new listener instance.

The documentation for this class was generated from the following file:
  • include/jh/asynchronous/slot.h