#include <SFBMemory.h>
Public Member Functions | |
void | reflex (const char type, PacketHandler ph) |
Define a reflex that is operational only when a packet is triggered from memory. | |
bool | dispatch (int maxPackets, u32 deadline) |
Reflex-trigger up to maxPackets currently remembered packets, so long as millis() has not yet exceeded deadline. | |
int | remember (const u8 *packet) |
Save a copy of packet for later redispatch (if memory is available to do so). | |
int | rememberUnread (const u8 *packet, u8 sourceOverride=MAX_FACE_INDEX) |
u8 * | makeNewMemory (u32 packetLength) |
bool | remembering () |
Determine if we are reacting to a memorized packet, rather than a 'real' packet (that has just arrived on a face). | |
void | forget () |
Specify that the current memory packet should be forgotten after the current packet handler finishes. | |
void | remember () |
Specify that the current memory packet should be remembered after the current packet handler finishes. | |
bool | forget (u32 index) |
Specify that the packet in slot index should be forgotten. | |
u8 * | get (const u32 index) |
Access the packet associated with slot index. | |
bool | fire (const u32 index) |
Reflex-trigger the packet stored in slot index, if any. | |
int | find (const u8 type) |
int | find (const char *prefix, const int len=-1) |
int | printf (const char *format,...) |
Formatting printing to a temporary local packet. | |
u8 | getFace () |
Returns WMEM. |
bool SFBMemory::dispatch | ( | int | maxPackets, | |
u32 | deadline | |||
) |
bool SFBMemory::fire | ( | const u32 | index | ) |
Reflex-trigger the packet stored in slot index, if any.
true
iff a packet was triggered, false
if slot index was emptybool SFBMemory::forget | ( | u32 | index | ) |
Specify that the packet in slot index should be forgotten.
Returns true
if a packet was successfully forgotten from slot index; returns false
if slot index did not currently contain a packet.
This method must be used with caution. In particular, it is up to the caller to ensure that the index forgotten still contains whatever packet the caller actually intends to forget. This will be true so long as no packet dispatching has occurred since the time the index was returned from remember(const u8 *), but will not be true in general: Once dispatching has occurred, the packet in slot index may be been dispatched and forgotten, and another packet may have been stored in that same index slot.
if
some packet was forgotten from slot index, and false
if slot index was already empty.void SFBMemory::forget | ( | ) | [inline] |
Specify that the current memory packet should be forgotten after the current packet handler finishes.
Only effective inside a packet handler that is handling a memorized packet. Note that forgetting memory packets after triggering reflexes is the default behavior, so this method usually doesn't need to be called explicitly.
Access the packet associated with slot index.
int SFBMemory::printf | ( | const char * | format, | |
... | ||||
) |
Formatting printing to a temporary local packet.
Equivalent to facePrint
(WMEM,format,...).
void SFBMemory::remember | ( | ) | [inline] |
Specify that the current memory packet should be remembered after the current packet handler finishes.
Only effective inside a packet handler that is handling a memorized packet. Normally, a memorized packet ia forgotten after it triggers a reflex once; if it is desired to cause an additional trigger sometime after the current packet handler is finished, this method must be called during packet handling.
int SFBMemory::remember | ( | const u8 * | packet | ) |
Save a copy of packet for later redispatch (if memory is available to do so).
Returns -1 if no room was available, else returns a 'slot number' in the range of 0..MAX_PACKETS_IN_MEMORY-1. This slot number can be used to forget the copied packet if desired (though this must be used with caution; see forget(u32) for details.)
bool SFBMemory::remembering | ( | ) | [inline] |
Determine if we are reacting to a memorized packet, rather than a 'real' packet (that has just arrived on a face).
Only valid inside packet handlers.
true
if the current packet handler was triggered by a memory packet; false
if not.