devicesbus stage
This commit is contained in:
@@ -59,7 +59,35 @@ public:
|
|||||||
this->release(*b);
|
this->release(*b);
|
||||||
delete b;
|
delete b;
|
||||||
});
|
});
|
||||||
}
|
BlockPtr allocate(std::size_t requiredSize)
|
||||||
|
{
|
||||||
|
if (requiredSize > m_blockSize) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
std::size_t slot = 0;
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lk(m_mutex);
|
||||||
|
if (m_freeSlots.empty()) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
slot = m_freeSlots.front();
|
||||||
|
m_freeSlots.pop();
|
||||||
|
m_inUse[slot] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* raw = new PoolBlock{
|
||||||
|
m_storage.data() + slot * m_blockSize,
|
||||||
|
m_blockSize,
|
||||||
|
requiredSize,
|
||||||
|
slot,
|
||||||
|
};
|
||||||
|
return BlockPtr(raw, [this](PoolBlock* b) {
|
||||||
|
if (!b) return;
|
||||||
|
this->release(*b);
|
||||||
|
delete b;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
void release(const PoolBlock& block)
|
void release(const PoolBlock& block)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,6 +36,17 @@ void DeviceBusManager::setDirtyCallback(std::function<void()> cb)
|
|||||||
|
|
||||||
bool DeviceBusManager::initialize(const QJsonObject& rootConfig)
|
bool DeviceBusManager::initialize(const QJsonObject& rootConfig)
|
||||||
{
|
{
|
||||||
|
// 初始化内存池、pipeline引擎、插件管理器、ingress适配器、egress路由器
|
||||||
|
// 内存池是用来存储数据块的
|
||||||
|
// pipeline引擎是用来处理数据流的
|
||||||
|
// 插件管理器是用来管理插件的
|
||||||
|
// ingress适配器是用来将数据推送到 ingress 队列的
|
||||||
|
// egress路由器是用来将数据从 ingress 队列中取出并发送给设备的
|
||||||
|
// 内存池大小为4096,每个数据块大小为4096
|
||||||
|
// pipeline引擎队列大小为4096
|
||||||
|
// 插件管理器插件数量为4096
|
||||||
|
// ingress适配器队列大小为4096
|
||||||
|
// egress路由器队列大小为4096
|
||||||
if (!m_memoryPool) {
|
if (!m_memoryPool) {
|
||||||
m_memoryPool = std::make_shared<softbus::core::memory::MemoryPool>(4096, 4096);
|
m_memoryPool = std::make_shared<softbus::core::memory::MemoryPool>(4096, 4096);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
// 功能 :定义有效载荷引用 包含数据块、偏移量、长度
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// 定义管道上下文 包含设备ID、端点、时间戳、协议提示、跟踪ID、有效载荷、有效载荷大小
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ void PipelineEngine::setPluginManager(std::shared_ptr<softbus::core::plugin_syst
|
|||||||
m_pluginManager = std::move(pluginManager);
|
m_pluginManager = std::move(pluginManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 管道引擎运行线程 从 ingress 队列中取出数据 进行处理 然后推送到 egress 队列中
|
||||||
void PipelineEngine::run()
|
void PipelineEngine::run()
|
||||||
{
|
{
|
||||||
while (m_running.load()) {
|
while (m_running.load()) {
|
||||||
@@ -77,9 +78,13 @@ void PipelineEngine::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
const bool framed = stage1Framer(ctx);
|
const bool framed = stage1Framer(ctx);
|
||||||
|
// 帧解析
|
||||||
const bool parsed = framed && stage2Parser(ctx);
|
const bool parsed = framed && stage2Parser(ctx);
|
||||||
|
// 过滤
|
||||||
const bool filtered = parsed && stage3Filter(ctx);
|
const bool filtered = parsed && stage3Filter(ctx);
|
||||||
|
// 验证
|
||||||
const bool valid = filtered && stage4Validator(ctx);
|
const bool valid = filtered && stage4Validator(ctx);
|
||||||
|
// 如果验证失败 则记录错误
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
++m_counters.error;
|
++m_counters.error;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
// 定义管道引擎 包含队列、运行状态、工作线程、计数器、插件管理器
|
||||||
|
// 队列是用来存储管道上下文的
|
||||||
|
// 运行状态是用来控制引擎的运行和停止的
|
||||||
|
// 工作线程是用来处理管道上下文的
|
||||||
|
// 计数器是用来统计管道上下文的数量和错误数量的
|
||||||
|
// 插件管理器是用来管理插件的
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|||||||
Reference in New Issue
Block a user