Template Class Duct¶
Defined in File Duct.hpp
Class Documentation¶
-
template<typename
ImplSpec>
classuit::internal::Duct¶ Performs data transmission between an
Inletand an `Outlet.Under the hood, a
Ductactually wraps astd::variantof three implementation types:IntraDuct: implementation type that performs transmission between anInletandOutletthat reside on the same thread in the same process.ThreadDuct: implementation type that performs transmission betweeen anInletandOutletthat reside on different threads, but are within the same process.ProcDuct: implementation type that performs transmission between anInletandOutletthat reside on different processes. (See note.)
The
std::varianttemplate represents a type-safe union. Astd::variantinstance holds an instance of just one of its alternative types. However, the type which astd::variantinstance holds may be freely determined and arbitrarily switched during the lifetime of the instance.When a
Ductis constructed, theIntraDuctimplementation is constructed and held by theDuct’sstd::variant. An alternate implementation (i.e., a thread-safe or process-safe implementaiton) may be emplaced within theDuct’sstd::variantby callingEmplaceDuct. This design enables theDuct’s active implementation to be switched at run-time, even if after theDucthas been already transmitted through. However, when theDuct’s implementation is switched, no attempt is made to transfer state (i.e., pending data) between the destructed implementation and its replacement. AllDuctoperations are forwarded to the active implementation type within aDuct’sstd::variant.The actual identity of the
IntraDuct,ThreadDuct, andProcDuctimplementations are themselves modular and may be specified via theImplSpectemplate paramater. You can find available intra-thread, inter-thread, and inter-process implementations within theinclude/ducts/intra,include/ducts/thread, andinclude/ducts/procdirectories, respectively. You may also supply your own implementations so long as they satisfy the method signatures within this class that are forwarded to thestd::variant’s active implementation.- Note
Because processes do not share memory space and inter-process communication code is typically asymmetric between the sender and receiver, the
ProcDuctimplementation actually corresponds to two distinct implementations: aProcInletDuctimplementaiton and aProcOutletDuctimplementation. TheProcInletDuctperforms the inter-process sending role and theProcOutletDuctperforms the inter-process receiving role. So, in reality aDuctwraps astd::variantof four implementation types.- Note
End users should probably never have to directly instantiate this class. The
Conduit,Sink, andSourceclasses take care of creating aDuctand tying it to anInletand/orOutlet. Better yet, theMeshTopologyinterface allows end users to construct a conduit network in terms of a connection topology and a mapping to assign nodes to threads and processes without having to manually constructConduitsand emplace necessary thread-safe and/or process-safeDuctimplementations.- Template Parameters
ImplSpec: class with static and typedef members specifying implementation details for the conduit framework. Seeinclude/config/ImplSpec.hpp.
Public Types
-
using
uid_t= std::uintptr_t¶ TODO.
Public Functions
-
template<typename ...
Args>Duct(Args&&... args)¶ Forwarding constructor.
Use
std::in_place_t<ImplType>followed by constructor arguments to initialize theDuctwithImplTypeactive.
-
template<typename
WhichDuct, typename ...Args>
voidEmplaceImpl(Args&&... args)¶ TODO.
- Template Parameters
WhichDuct: TODOArgs: TODO
- Parameters
args: TODO
-
bool
TryPut(const T &val)¶ TODO.
- Return
TODO.
- Parameters
val: TODO.
-
bool
TryFlush()¶ TODO.
-
const T &
Get() const¶ TODO.
- Return
TODO.
-
T &
Get()¶ TODO.
- Return
TODO.
-
size_t
TryConsumeGets(const size_t requested)¶ TODO.
- Return
number of gets actually consumed.
- Parameters
count: maximum number of gets to consume.
-
std::string
WhichImplIsActive() const¶ TODO.
- Return
TODO.
-
emp::optional<bool>
HoldsIntraImpl() const¶ TODO.
- Return
TODO.
-
emp::optional<bool>
HoldsThreadImpl() const¶ TODO.
- Return
TODO.
-
emp::optional<bool>
HoldsProcImpl() const¶ TODO.
- Return
TODO.
-
bool
CanStep() const¶
-
std::string
ToString() const¶ TODO.
- Return
TODO.