Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
taskbus
提交
e9f8829d
taskbus
项目概览
colorEagleStdio
/
taskbus
通知
159
Star
11
Fork
3
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
taskbus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e9f8829d
编写于
10月 21, 2023
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
使用 QEvent 而非 信号和槽 进行高流量吞吐
上级
4571acb3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
21 deletion
+23
-21
taskbusplatform/core/tasknode.cpp
taskbusplatform/core/tasknode.cpp
+18
-18
taskbusplatform/core/tasknode.h
taskbusplatform/core/tasknode.h
+5
-3
未找到文件。
taskbusplatform/core/tasknode.cpp
浏览文件 @
e9f8829d
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
#include "process_prctl.h"
#include "process_prctl.h"
#include "../watchdog/tbwatchdog.h"
#include "../watchdog/tbwatchdog.h"
#include "../watchdog/profile_log.h"
#include "../watchdog/profile_log.h"
QEvent
::
Type
taskNode
::
m_nPackEvent
=
(
QEvent
::
Type
)
QEvent
::
registerEventType
();
taskNode
::
taskNode
(
QObject
*
parent
)
taskNode
::
taskNode
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
m_process
(
new
QProcess
(
this
))
,
m_process
(
new
QProcess
(
this
))
...
@@ -38,8 +40,8 @@ taskNode::taskNode(QObject *parent)
...
@@ -38,8 +40,8 @@ taskNode::taskNode(QObject *parent)
&
taskNode
::
slot_readyReadStandardError
/*,Qt::QueuedConnection*/
);
&
taskNode
::
slot_readyReadStandardError
/*,Qt::QueuedConnection*/
);
connect
(
m_process
,
&
QProcess
::
bytesWritten
,
this
,
connect
(
m_process
,
&
QProcess
::
bytesWritten
,
this
,
&
taskNode
::
slot_sended
);
&
taskNode
::
slot_sended
);
connect
(
this
,
&
taskNode
::
sig_new_package
,
this
,
&
taskNode
::
slot_write
,
Qt
::
QueuedConnection
);
m_nBp_TimerID
=
startTimer
(
200
);
m_nBp_TimerID
=
startTimer
(
200
);
}
}
taskNode
::~
taskNode
()
taskNode
::~
taskNode
()
{
{
...
@@ -232,8 +234,8 @@ void taskNode::slot_readyReadStandardOutput()
...
@@ -232,8 +234,8 @@ void taskNode::slot_readyReadStandardOutput()
emit
sig_new_command
(
map_z
);
emit
sig_new_command
(
map_z
);
}
}
}
}
else
else
if
(
m_currPrj
)
emit_package
(
pack_header
,
pack_size
);
m_currPrj
->
routing_new_package
(
this
,
pack_header
,
pack_size
);
if
(
m_bDebug
)
if
(
m_bDebug
)
log_package
(
true
,
pack_header
,
pack_size
);
log_package
(
true
,
pack_header
,
pack_size
);
startByte
+=
pack_size
;
startByte
+=
pack_size
;
...
@@ -286,19 +288,6 @@ void taskNode::emit_message(QByteArray arred)
...
@@ -286,19 +288,6 @@ void taskNode::emit_message(QByteArray arred)
}
}
}
}
/*!
* \brief taskNode::emit_package
* * Signals and Slots is easy to use, but it will take too much cpu resource with out bufferring .
* 没有缓存机制,频繁的发送信号,将降低系统的性能。
* We will check the timestamp between 2 signals, catch it , and send it out as a batch list.
* \param package
*/
void
taskNode
::
emit_package
(
char
*
package
,
qsizetype
sz
)
{
if
(
m_currPrj
)
m_currPrj
->
routing_new_package
(
this
,
package
,
sz
);
}
void
taskNode
::
flush_from_stderr
()
void
taskNode
::
flush_from_stderr
()
{
{
if
(
m_arr_Strerr
.
size
())
if
(
m_arr_Strerr
.
size
())
...
@@ -380,10 +369,21 @@ bool taskNode::enqueue_write(const char * pack, qsizetype sz)
...
@@ -380,10 +369,21 @@ bool taskNode::enqueue_write(const char * pack, qsizetype sz)
m_mtxPackage
.
unlock
();
m_mtxPackage
.
unlock
();
++
m_spackage_recieved
;
++
m_spackage_recieved
;
if
(
!
z
)
if
(
!
z
)
emit
sig_new_package
();
{
QCoreApplication
::
postEvent
(
this
,
new
QEvent
(
m_nPackEvent
),
Qt
::
HighEventPriority
);
//emit sig_new_package();
}
return
true
;
return
true
;
}
}
void
taskNode
::
slot_write
()
void
taskNode
::
customEvent
(
QEvent
*
evt
)
{
if
(
evt
->
type
()
==
m_nPackEvent
)
{
flush_write
();
}
}
void
taskNode
::
flush_write
()
{
{
m_mtxPackage
.
lock
();
m_mtxPackage
.
lock
();
if
(
m_bDebug
)
if
(
m_bDebug
)
...
...
taskbusplatform/core/tasknode.h
浏览文件 @
e9f8829d
...
@@ -19,7 +19,9 @@
...
@@ -19,7 +19,9 @@
#include <QByteArrayList>
#include <QByteArrayList>
#include <QFile>
#include <QFile>
#include <QMutex>
#include <QMutex>
#include <QEvent>
class
taskCell
;
class
taskCell
;
class
taskProject
;
class
taskProject
;
/*!
/*!
* \brief The taskNode class 管理一个构件进程的类
* \brief The taskNode class 管理一个构件进程的类
...
@@ -38,7 +40,6 @@ signals:
...
@@ -38,7 +40,6 @@ signals:
void
sig_pro_started
();
void
sig_pro_started
();
void
sig_pro_stopped
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
);
void
sig_pro_stopped
(
int
exitCode
,
QProcess
::
ExitStatus
exitStatus
);
void
sig_new_command
(
QMap
<
QString
,
QVariant
>
cmd
);
void
sig_new_command
(
QMap
<
QString
,
QVariant
>
cmd
);
void
sig_new_package
();
void
sig_new_errmsg
(
QByteArrayList
);
void
sig_new_errmsg
(
QByteArrayList
);
void
sig_iostat
(
qint64
pid
,
quint64
pr
,
quint64
ps
,
quint64
br
,
quint64
bs
);
void
sig_iostat
(
qint64
pid
,
quint64
pr
,
quint64
ps
,
quint64
br
,
quint64
bs
);
public
slots
:
public
slots
:
...
@@ -50,7 +51,6 @@ private slots:
...
@@ -50,7 +51,6 @@ private slots:
void
slot_readyReadStandardOutput
();
void
slot_readyReadStandardOutput
();
void
slot_readyReadStandardError
();
void
slot_readyReadStandardError
();
void
slot_sended
(
qint64
);
void
slot_sended
(
qint64
);
void
slot_write
();
void
slot_started
(
);
void
slot_started
(
);
void
slot_stopped
();
void
slot_stopped
();
private:
private:
...
@@ -66,6 +66,7 @@ private:
...
@@ -66,6 +66,7 @@ private:
void
flush_from_stderr
();
void
flush_from_stderr
();
private:
private:
void
log_package
(
bool
fromStdOut
,
char
*
pkg
,
qsizetype
sz
);
void
log_package
(
bool
fromStdOut
,
char
*
pkg
,
qsizetype
sz
);
void
flush_write
();
QFile
m_dbgfile_stdin
;
QFile
m_dbgfile_stdin
;
QFile
m_dbgfile_stdout
;
QFile
m_dbgfile_stdout
;
QFile
m_dbgfile_stderr
;
QFile
m_dbgfile_stderr
;
...
@@ -77,7 +78,6 @@ private:
...
@@ -77,7 +78,6 @@ private:
QString
dbgdir
();
QString
dbgdir
();
//Call these functions to emit message and packs with bufferring approach.
//Call these functions to emit message and packs with bufferring approach.
void
emit_message
(
QByteArray
a
);
void
emit_message
(
QByteArray
a
);
void
emit_package
(
char
*
pack
,
qsizetype
sz
);
public:
public:
void
setBlockFlag
(
bool
b
);
void
setBlockFlag
(
bool
b
);
void
setCurrentProject
(
taskProject
*
p
);
void
setCurrentProject
(
taskProject
*
p
);
...
@@ -85,8 +85,10 @@ public:
...
@@ -85,8 +85,10 @@ public:
protected:
protected:
int
m_nBatchTime
=
20
;
int
m_nBatchTime
=
20
;
int
m_nBp_TimerID
=
-
1
;
int
m_nBp_TimerID
=
-
1
;
static
QEvent
::
Type
m_nPackEvent
;
taskCell
*
m_pCell
=
nullptr
;
taskCell
*
m_pCell
=
nullptr
;
void
timerEvent
(
QTimerEvent
*
event
);
void
timerEvent
(
QTimerEvent
*
event
);
void
customEvent
(
QEvent
*
evt
)
override
;
//statistic
//statistic
protected:
protected:
quint64
m_spackage_recieved
=
0
;
quint64
m_spackage_recieved
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录