Sen API
Sen Libraries
Loading...
Searching...
No Matches
sen::kernel Namespace Reference

Strong type for the unique identifier for a transport timer. More...

Namespaces

namespace  crash
 Crash reporting, which belongs to the process rather than to any one kernel: a process has one crash reporter however many kernels it builds.

Classes

class  Bootloader
 Configures a kernel for running. More...
struct  BusId
class  Component
 Base class for implementing sen kernel components. More...
struct  ComponentContext
 Holds a component instance and basic info. More...
struct  ComponentMonitoringInfo
 Runtime monitoring information about a single component runner. More...
class  ConfigGetter
 Allows for fetching configuration parameters. More...
class  InitApi
 What can be done when initializing a component. More...
class  Kernel
 Main entry point of a sen microkernel. More...
class  KernelApi
 User-facing kernel functions. More...
class  KernelConfig
 Holds the kernel configuration information. More...
struct  KernelMonitoringInfo
 Kernel runtime monitoring information. More...
class  LoadApi
 What can be done when loading a component. More...
struct  LoggerSinkRegistration
 What registering a logger sink did. More...
class  PackageManager
 Utility class for loading types from Sen packages. More...
struct  ParticipantAddr
 To identify remote participants. More...
class  PreloadApi
 What can be done when preloading a component. More...
class  RegistrationApi
 API for objects when registered. More...
class  RunApi
 What can be done while a component is running. More...
class  SessionInfoProvider
class  SessionsDiscoverer
class  SourceInfo
 Provides information about sources as strings. More...
class  TestComponent
 Convenience class for using lambdas instead of inheritance when defining test components. More...
class  TestKernel
 Kernel class only meant for unit testing your packages or components. It starts in virtual time mode. More...
class  Tracer
 Interface implemented by tracers. You can use it to trace the behavior of your code. Please note that not all tracers support the functions below. More...
class  Transport
 Interface for implementing a Sen inter-process transport solution. More...
class  TransportListener
 Interface for the internal Sen element that reacts to transport events. More...
struct  TransportStats
 Global transport statistics. More...
class  UniqueByteBufferManager
class  UnloadApi
 What can be done when unloading a component. More...

Typedefs

using FuncResult = Result<void, ExecError>
 The result of operations that are called once.
using PassResult = Result<OpState, ExecError>
 The result of operations that may be called multiple times.
using NetworkFootprintReporter = NetworkFootprint(Span<const BusAddress>) const
 Callable that builds a network footprint from bus addresses.
using TracerFactory = std::function<std::unique_ptr<Tracer>(std::string_view)>
 A factory function for tracers.
using BestEffortBlockPtr = std::shared_ptr<FixedMemoryBlock>
 Pointer to a memory block of fixed size, used for best effort communication.
using ReliableBlockPtr = std::shared_ptr<ResizableHeapBlock>
 Pointer to a resizable memory block, used for reliable communication.
using BestEffortBufferList = std::vector<BestEffortBlockPtr>
 A list (vector) of fixed-size memory blocks.
using TransportFactory = std::function<std::unique_ptr<Transport>(const std::string&, std::unique_ptr<Tracer> tracer)>
 A function that creates a transport given a session name.

Enumerations

enum class  TerminalOwnership { shared , owned }
 Whether the component registering a log sink owns the terminal. More...
enum class  KernelBlockMode { doNotBlock , doBlock }
 How to deal with the thread that calls the Kernel::run() function. More...

Functions

VarMap getConfigAsVarFromYaml (const std::filesystem::path &path, bool printFinalConfig=false)
 Loads a configuration YAML file and returns its contents as a sen::VarMap. This function does not validate the correctness of the configuration, but simply translates the contents into the Var. It resolves included yamls.
VarMap getConfigAsVarFromYaml (const std::string &content, const std::filesystem::path &path, bool printFinalConfig=false)
 Loads a configuration YAML file and returns its contents as a sen::VarMap. This function does not validate the correctness of the configuration, but simply translates the contents into the Var. It resolves included yamls. If the "path" argument is not correct, it will not resolve the inclusions.
PassResult done ()
 Convenience helper for doing sen::Ok(sen::kernel::OpState {sen::kernel::OpFinished {}}).
constexpr bool getDebugEnabled () noexcept
constexpr WordSize getWordSize () noexcept
SEN_PRIVATE const char * getGitRef () noexcept
SEN_PRIVATE const char * getGitHash () noexcept
SEN_PRIVATE GitStatus getGitStatus () noexcept
SEN_PRIVATE const char * getBuildTime () noexcept
TracerFactory getDefaultTracerFactory ()
 A function that returns a no-op tracer.
bool operator== (const ParticipantAddr &lhs, const ParticipantAddr &rhs) noexcept
bool operator!= (const ParticipantAddr &lhs, const ParticipantAddr &rhs) noexcept
uint32_t getKernelProtocolVersion () noexcept
 The protocol version of kernel messaging.
CustomTypeSpec makeCustomTypeSpec (const CustomType *type)
 Implementation detail for the kernel.
bool equivalent (const Type *localType, const Type *remoteType)
 Checks if two meta types are equivalent (same hash).
ConstTypeHandle< CustomType > buildNonNativeType (const CustomTypeSpec &remoteType, const CustomTypeRegistry &nativeTypes, const CustomTypeRegistry &nonNativeTypes)
 Implementation detail for the kernel.
std::vector< std::string > getRuntimeDifferences (const Type *localType, const Type *remoteType)
 Detects which differences cause.
bool acceptsUnderCompatibilityMode (CompatibilityMode mode, bool typesAreEquivalent, bool anyConversionLosesData) noexcept
 Whether a runtime-compatible remote type may still be used, under a compatibility mode. One that is not runtime-compatible is refused before this is asked.
std::vector< std::string > runtimeCompatible (const Type *localType, const Type *remoteType, std::vector< std::string > *lossy=nullptr)
 Checks if two types are runtime-compatible and returns the error string in case they are not. When lossy is given, it also collects the conversions that are allowed but can drop a value.
CustomTypeSpec toCurrentVersion (const CustomTypeSpecV4 &v4)
 Translates a CustomTypeSpec from V4 to the current version (V6) of the kernel protocol.
CustomTypeSpec toCurrentVersion (const CustomTypeSpecV5 &v5)
 Translates a CustomTypeSpec from V5 to the current version (V6) of the kernel protocol.
ProcessInfo getOwnProcessInfo (std::string_view sessionName)
 Utility function to fetch our process info.
uint32_t getHostId ()
 Utility function to fetch our host ID.
uint32_t getUniqueSenProcessId ()
 Utility function to fetch our process ID.

Variables

constexpr auto * componentMakerFuncName = SEN_STRINGIFY(SEN_COMPONENT_MAKER)
constexpr auto * componentInfoMakerFuncName = SEN_STRINGIFY(SEN_COMPONENT_INFO_MAKER)
constexpr std::size_t maxBestEffortMessageSize = 65527U
 The maximum UDP payload size.

Detailed Description

Strong type for the unique identifier for a transport timer.


Class Documentation

◆ sen::kernel::ComponentMonitoringInfo

struct sen::kernel::ComponentMonitoringInfo

Runtime monitoring information about a single component runner.

Class Members
string name
uint32_t group = 0
bool requiresRealTime = false
optional< Duration > cycleTime
size_t objectCount = 0
optional< Duration > lastCycleExecutionCpuTime Thread CPU time, user and system, consumed by the last completed execution cycle. On Windows every CPU time here is quantised to the system clock tick, 15.6 ms by default, so for a shorter period than that these figures say very little.
optional< Duration > lastCycleComponentCpuTime The part of that spent in the component's own code: its objects' update() and its work function. Its preDrain() and preCommit(), its commit-time event handlers and its discovery callbacks run outside this and are counted with Sen's.
optional< Duration > lastCycleQueuedWorkCpuTime The part of that spent on work queued on the component: the callbacks it registered, and serving the calls other components make on its objects. Serving a call is partly the component's method and partly Sen's transport, so it is reported on its own.
optional< Duration > worstCycleExecutionCpuTime The most CPU time any one cycle has used since the component started running, leaving out its first cycle, which carries the startup. A component that runs long once in a thousand cycles rarely has it in the last one.
optional< Duration > worstCycleComponentCpuTime The component's share of that same worst cycle, so the two can be compared.
optional< Duration > lastCycleStartDelay How late the thread woke for the cycle it was waiting for. The scheduler's contribution, kept apart from the component's. Negative if it woke early. Empty for the first cycle, and unless the component runs on the kernel's real-time loop.
optional< Duration > worstStartDelay The latest the thread has ever woken. A machine that is late once in a thousand cycles rarely has it in lastCycleStartDelay.
optional< uint64_t > overrunCount Cycles whose execution used more CPU time than the period. A cycle that blocked rather than computed does not appear here, it appears in missedFrameCount. A cycle that overruns also finishes past its slot, so missedFrameCount rises with it. Empty unless the component runs on the kernel's real-time loop.
optional< uint64_t > missedFrameCount Cycles lost because the work finished after the cycle it belonged to. Every lost cycle is counted, not the run of them. Wall time, so blocking counts, and so does a clock correction that moves the schedule forward. The first cycle is not counted: the schedule starts before the component has finished its own startup. Empty unless the component runs on the kernel's real-time loop.
optional< uint64_t > oversleptCount Cycles lost because the sleep returned late, so the component was not running when it should have been. Every lost cycle is counted, not the run of them. A wake-up late by less than a period loses no cycle here and shows up in missedFrameCount, so read lastCycleStartDelay before blaming the component. Empty unless it runs on the kernel's real-time loop.

◆ sen::kernel::KernelMonitoringInfo

struct sen::kernel::KernelMonitoringInfo

Kernel runtime monitoring information.

Class Members
RunMode runMode = RunMode::realTime
TransportStats transportStats {}
vector< ComponentMonitoringInfo > components

◆ sen::kernel::LoggerSinkRegistration

struct sen::kernel::LoggerSinkRegistration

What registering a logger sink did.

There is no arbitration: a sink is added, never refused, so two components that both render logs will each be handed every line, including the other's. Anything that needs exclusivity has to read registeredSinks and decide for itself.

Class Members
bool added = false false when this sink was already registered, so the call only changed its terminal ownership
bool ownsTerminal = false whether this sink now holds the terminal claim
bool terminalOwnedElsewhere = false whether a different registered sink holds the claim
size_t registeredSinks = 0 sinks registered behind the relay, this one included

Typedef Documentation

◆ FuncResult

using sen::kernel::FuncResult = Result<void, ExecError>

The result of operations that are called once.

◆ PassResult

using sen::kernel::PassResult = Result<OpState, ExecError>

The result of operations that may be called multiple times.

◆ NetworkFootprintReporter

using sen::kernel::NetworkFootprintReporter = NetworkFootprint(Span<const BusAddress>) const

Callable that builds a network footprint from bus addresses.

◆ TracerFactory

using sen::kernel::TracerFactory = std::function<std::unique_ptr<Tracer>(std::string_view)>

A factory function for tracers.

Enumeration Type Documentation

◆ TerminalOwnership

enum class sen::kernel::TerminalOwnership
strong

Whether the component registering a log sink owns the terminal.

shared leaves console output alone. owned silences every console sink, now and on every logger made while the claim lasts: a console sink writes to the descriptor the component is drawing on, so its output would land on top of the display and every line would appear twice. Silencing rather than detaching is what makes it reversible, and removeLoggerSink puts every console sink back to the level it had once no registered sink claims the terminal.

Re-adding a sink that is already registered, with owned, claims the terminal for it. A shared add never gives a claim up.

Enumerator
shared 
owned 

◆ KernelBlockMode

enum class sen::kernel::KernelBlockMode
strong

How to deal with the thread that calls the Kernel::run() function.

Enumerator
doNotBlock 

Does not block the caller thread.

doBlock 

Blocks the caller thread.

Function Documentation

◆ done()

PassResult sen::kernel::done ( )
inlinenodiscard

Convenience helper for doing sen::Ok(sen::kernel::OpState {sen::kernel::OpFinished {}}).

◆ getDebugEnabled()

bool sen::kernel::getDebugEnabled ( )
nodiscardconstexprnoexcept

◆ getWordSize()

WordSize sen::kernel::getWordSize ( )
nodiscardconstexprnoexcept

◆ getGitRef()

SEN_PRIVATE const char * sen::kernel::getGitRef ( )
nodiscardnoexcept

◆ getGitHash()

SEN_PRIVATE const char * sen::kernel::getGitHash ( )
nodiscardnoexcept

◆ getGitStatus()

SEN_PRIVATE GitStatus sen::kernel::getGitStatus ( )
nodiscardnoexcept

◆ getBuildTime()

SEN_PRIVATE const char * sen::kernel::getBuildTime ( )
nodiscardnoexcept

◆ getDefaultTracerFactory()

TracerFactory sen::kernel::getDefaultTracerFactory ( )
nodiscard

A function that returns a no-op tracer.

◆ getOwnProcessInfo()

ProcessInfo sen::kernel::getOwnProcessInfo ( std::string_view sessionName)

Utility function to fetch our process info.

◆ getHostId()

uint32_t sen::kernel::getHostId ( )
nodiscard

Utility function to fetch our host ID.

◆ getUniqueSenProcessId()

uint32_t sen::kernel::getUniqueSenProcessId ( )
nodiscard

Utility function to fetch our process ID.

Variable Documentation

◆ componentMakerFuncName

auto* sen::kernel::componentMakerFuncName = SEN_STRINGIFY(SEN_COMPONENT_MAKER)
constexpr

◆ componentInfoMakerFuncName

auto* sen::kernel::componentInfoMakerFuncName = SEN_STRINGIFY(SEN_COMPONENT_INFO_MAKER)
constexpr