mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Initial commit
This commit is contained in:
commit
6c7efdd0f6
59 changed files with 8604 additions and 0 deletions
34
src/helpers/StaticPoolPacketManager.h
Normal file
34
src/helpers/StaticPoolPacketManager.h
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#include <Dispatcher.h>
|
||||
|
||||
class PacketQueue {
|
||||
mesh::Packet** _table;
|
||||
uint8_t* _pri_table;
|
||||
uint32_t* _schedule_table;
|
||||
int _size, _num;
|
||||
|
||||
public:
|
||||
PacketQueue(int max_entries);
|
||||
mesh::Packet* get(uint32_t now);
|
||||
void add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for);
|
||||
int count() const { return _num; }
|
||||
mesh::Packet* itemAt(int i) const { return _table[i]; }
|
||||
mesh::Packet* removeByIdx(int i);
|
||||
};
|
||||
|
||||
class StaticPoolPacketManager : public mesh::PacketManager {
|
||||
PacketQueue unused, send_queue;
|
||||
|
||||
public:
|
||||
StaticPoolPacketManager(int pool_size);
|
||||
|
||||
mesh::Packet* allocNew() override;
|
||||
void free(mesh::Packet* packet) override;
|
||||
void queueOutbound(mesh::Packet* packet, uint8_t priority, uint32_t scheduled_for) override;
|
||||
mesh::Packet* getNextOutbound(uint32_t now) override;
|
||||
int getOutboundCount() const override;
|
||||
int getFreeCount() const override;
|
||||
mesh::Packet* getOutboundByIdx(int i) override;
|
||||
mesh::Packet* removeOutboundByIdx(int i) override;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue