35#ifndef _UTILS_BUSMASTER_HXX_
36#define _UTILS_BUSMASTER_HXX_
45template <
class MessageType>
class Bus
101 void request_shutdown()
BufferPtr< T > get_buffer_deleter(Buffer< T > *b)
Helper function to create a BufferPtr of an appropriate type without having to explicitly specify the...
AutoReleaseBuffer< T > BufferPtr
Smart pointer for buffers.
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
Base class for all QMember types that hold data in an expandable format.
Abstract class that gets scheduled for polling and when the master decides to take it,...
virtual void fill_packet(Packet *packet)=0
Complete a packet to send to the bus.
void set_policy(unsigned num_prio, const Fixed16 *strides)
Sets the scheduling policy.
uint16_t needShutdown_
True if shutdown was requested.
Action get_buffer()
Start of scheduling flow.
PacketSink * sink_
Where to send the generated packets.
Master(Service *s, PacketSink *sink, Activity *idle, unsigned num_enqueued)
Constructor.
void schedule_activity(Activity *a, unsigned prio)
Adds an activity to the bus master's scheduler.
Activity * idle_
If we have no activity to do, this activity gets invoked.
LimitedPool pool_
Source of the buffers that we fill and hand out.
Action fill_pkt()
Executes the scheduling decision, fills in the packet by the selected activity and sends it to the bu...
uninitialized< ScheduledQueue > queue_
Handles the policy of polling.
uint16_t numPacketsInPool_
Total number of packets that the pool can generate.
This is a namespace class that contains a variety of related classes for handling a bus that needs a ...
BufferPtr< MessageType > PacketPtr
Self-owned buffer type.
Buffer< MessageType > Packet
The buffer type that is handed around to the different participants.
Bus()
This class cannot be instantiated.
Abstract class for message recipients.
virtual void send(MessageType *message, unsigned priority=UINT_MAX)=0
Entry point to the flow.
Implementation of a Pool interface that takes memory from mainBufferPool (configurable) but limits th...
size_t free_items() override
Number of free items in the pool.
Essentially a "next" pointer container.
void insert(QMember *item, unsigned prio)
Adds an entry to the queue.
Result next()
Get an item from the queue.
Collection of related state machines that pend on incoming messages.
Return type for a state flow callback.
Base class for state machines.
Action allocate_and_call(FlowInterface< Buffer< T > > *target_flow, Callback c, Pool *pool=nullptr)
Allocates a buffer from a pool and proceed to the next state when allocation is successful.
Action exit()
Terminate current StateFlow activity.
void start_flow(Callback c)
Resets the flow to the specified state and starts it.
Buffer< T > * get_allocation_result(FlowInterface< Buffer< T > > *target_flow)
Takes the result of the asynchronous allocation.
Action call_immediately(Callback c)
Imediately call the next state upon return.
Template class that allows allocating storage for an object but not calling its constructor.
T & emplace(Args &&... args)
Constructs the embedded object.
QMember * item
item pulled from queue