Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
2f30a84a
Unverified
提交
2f30a84a
authored
7月 04, 2024
作者:
Lynnworld
提交者:
GitHub
7月 04, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flatbuffer builder reuse (#1422)
上级
9d9e358b
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
16 行增加
和
12 行删除
+16
-12
ChannelNotifier.hpp
worker/include/Channel/ChannelNotifier.hpp
+2
-2
ChannelRequest.hpp
worker/include/Channel/ChannelRequest.hpp
+4
-4
ChannelRequest.cpp
worker/src/Channel/ChannelRequest.cpp
+9
-5
ChannelSocket.cpp
worker/src/Channel/ChannelSocket.cpp
+1
-1
没有找到文件。
worker/include/Channel/ChannelNotifier.hpp
浏览文件 @
2f30a84a
...
@@ -34,7 +34,7 @@ namespace Channel
...
@@ -34,7 +34,7 @@ namespace Channel
builder
.
FinishSizePrefixed
(
message
);
builder
.
FinishSizePrefixed
(
message
);
this
->
channel
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
this
->
channel
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
builder
.
Reset
();
builder
.
Clear
();
}
}
void
Emit
(
const
std
::
string
&
targetId
,
FBS
::
Notification
::
Event
event
)
void
Emit
(
const
std
::
string
&
targetId
,
FBS
::
Notification
::
Event
event
)
...
@@ -48,7 +48,7 @@ namespace Channel
...
@@ -48,7 +48,7 @@ namespace Channel
builder
.
FinishSizePrefixed
(
message
);
builder
.
FinishSizePrefixed
(
message
);
this
->
channel
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
this
->
channel
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
builder
.
Reset
();
builder
.
Clear
();
}
}
private
:
private
:
...
...
worker/include/Channel/ChannelRequest.hpp
浏览文件 @
2f30a84a
...
@@ -22,6 +22,7 @@ namespace Channel
...
@@ -22,6 +22,7 @@ namespace Channel
public
:
public
:
static
absl
::
flat_hash_map
<
FBS
::
Request
::
Method
,
const
char
*>
method2String
;
static
absl
::
flat_hash_map
<
FBS
::
Request
::
Method
,
const
char
*>
method2String
;
thread_local
static
flatbuffers
::
FlatBufferBuilder
bufferBuilder
;
public
:
public
:
ChannelRequest
(
Channel
::
ChannelSocket
*
channel
,
const
FBS
::
Request
::
Request
*
request
);
ChannelRequest
(
Channel
::
ChannelSocket
*
channel
,
const
FBS
::
Request
::
Request
*
request
);
...
@@ -29,7 +30,7 @@ namespace Channel
...
@@ -29,7 +30,7 @@ namespace Channel
flatbuffers
::
FlatBufferBuilder
&
GetBufferBuilder
()
flatbuffers
::
FlatBufferBuilder
&
GetBufferBuilder
()
{
{
return
this
->
bufferBuilder
;
return
ChannelRequest
::
bufferBuilder
;
}
}
void
Accept
();
void
Accept
();
template
<
class
Body
>
template
<
class
Body
>
...
@@ -39,7 +40,7 @@ namespace Channel
...
@@ -39,7 +40,7 @@ namespace Channel
this
->
replied
=
true
;
this
->
replied
=
true
;
auto
&
builder
=
this
->
bufferBuilder
;
auto
&
builder
=
ChannelRequest
::
bufferBuilder
;
auto
response
=
FBS
::
Response
::
CreateResponse
(
builder
,
this
->
id
,
true
,
type
,
body
.
Union
());
auto
response
=
FBS
::
Response
::
CreateResponse
(
builder
,
this
->
id
,
true
,
type
,
body
.
Union
());
auto
message
=
auto
message
=
...
@@ -47,7 +48,7 @@ namespace Channel
...
@@ -47,7 +48,7 @@ namespace Channel
builder
.
FinishSizePrefixed
(
message
);
builder
.
FinishSizePrefixed
(
message
);
this
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
this
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
builder
.
Reset
();
builder
.
Clear
();
}
}
void
Error
(
const
char
*
reason
=
nullptr
);
void
Error
(
const
char
*
reason
=
nullptr
);
void
TypeError
(
const
char
*
reason
=
nullptr
);
void
TypeError
(
const
char
*
reason
=
nullptr
);
...
@@ -61,7 +62,6 @@ namespace Channel
...
@@ -61,7 +62,6 @@ namespace Channel
Channel
::
ChannelSocket
*
channel
{
nullptr
};
Channel
::
ChannelSocket
*
channel
{
nullptr
};
const
FBS
::
Request
::
Request
*
data
{
nullptr
};
const
FBS
::
Request
::
Request
*
data
{
nullptr
};
// Others.
// Others.
flatbuffers
::
FlatBufferBuilder
bufferBuilder
{};
uint32_t
id
{
0u
};
uint32_t
id
{
0u
};
Method
method
;
Method
method
;
const
char
*
methodCStr
;
const
char
*
methodCStr
;
...
...
worker/src/Channel/ChannelRequest.cpp
浏览文件 @
2f30a84a
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
namespace
Channel
namespace
Channel
{
{
/* Static variables. */
thread_local
flatbuffers
::
FlatBufferBuilder
ChannelRequest
::
bufferBuilder
{};
/* Class variables. */
/* Class variables. */
// clang-format off
// clang-format off
...
@@ -119,7 +123,7 @@ namespace Channel
...
@@ -119,7 +123,7 @@ namespace Channel
this
->
replied
=
true
;
this
->
replied
=
true
;
auto
&
builder
=
this
->
bufferBuilder
;
auto
&
builder
=
ChannelRequest
::
bufferBuilder
;
auto
response
=
auto
response
=
FBS
::
Response
::
CreateResponse
(
builder
,
this
->
id
,
true
,
FBS
::
Response
::
Body
::
NONE
,
0
);
FBS
::
Response
::
CreateResponse
(
builder
,
this
->
id
,
true
,
FBS
::
Response
::
Body
::
NONE
,
0
);
...
@@ -134,7 +138,7 @@ namespace Channel
...
@@ -134,7 +138,7 @@ namespace Channel
this
->
replied
=
true
;
this
->
replied
=
true
;
auto
&
builder
=
this
->
bufferBuilder
;
auto
&
builder
=
ChannelRequest
::
bufferBuilder
;
auto
response
=
FBS
::
Response
::
CreateResponseDirect
(
auto
response
=
FBS
::
Response
::
CreateResponseDirect
(
builder
,
this
->
id
,
false
/*accepted*/
,
FBS
::
Response
::
Body
::
NONE
,
0
,
"Error"
/*Error*/
,
reason
);
builder
,
this
->
id
,
false
/*accepted*/
,
FBS
::
Response
::
Body
::
NONE
,
0
,
"Error"
/*Error*/
,
reason
);
...
@@ -149,7 +153,7 @@ namespace Channel
...
@@ -149,7 +153,7 @@ namespace Channel
this
->
replied
=
true
;
this
->
replied
=
true
;
auto
&
builder
=
this
->
bufferBuilder
;
auto
&
builder
=
ChannelRequest
::
bufferBuilder
;
auto
response
=
FBS
::
Response
::
CreateResponseDirect
(
auto
response
=
FBS
::
Response
::
CreateResponseDirect
(
builder
,
this
->
id
,
false
/*accepted*/
,
FBS
::
Response
::
Body
::
NONE
,
0
,
"TypeError"
/*Error*/
,
reason
);
builder
,
this
->
id
,
false
/*accepted*/
,
FBS
::
Response
::
Body
::
NONE
,
0
,
"TypeError"
/*Error*/
,
reason
);
...
@@ -163,12 +167,12 @@ namespace Channel
...
@@ -163,12 +167,12 @@ namespace Channel
void
ChannelRequest
::
SendResponse
(
const
flatbuffers
::
Offset
<
FBS
::
Response
::
Response
>&
response
)
void
ChannelRequest
::
SendResponse
(
const
flatbuffers
::
Offset
<
FBS
::
Response
::
Response
>&
response
)
{
{
auto
&
builder
=
this
->
bufferBuilder
;
auto
&
builder
=
ChannelRequest
::
bufferBuilder
;
auto
message
=
auto
message
=
FBS
::
Message
::
CreateMessage
(
builder
,
FBS
::
Message
::
Body
::
Response
,
response
.
Union
());
FBS
::
Message
::
CreateMessage
(
builder
,
FBS
::
Message
::
Body
::
Response
,
response
.
Union
());
builder
.
FinishSizePrefixed
(
message
);
builder
.
FinishSizePrefixed
(
message
);
this
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
this
->
Send
(
builder
.
GetBufferPointer
(),
builder
.
GetSize
());
builder
.
Reset
();
builder
.
Clear
();
}
}
}
// namespace Channel
}
// namespace Channel
worker/src/Channel/ChannelSocket.cpp
浏览文件 @
2f30a84a
...
@@ -162,7 +162,7 @@ namespace Channel
...
@@ -162,7 +162,7 @@ namespace Channel
this
->
bufferBuilder
.
FinishSizePrefixed
(
message
);
this
->
bufferBuilder
.
FinishSizePrefixed
(
message
);
this
->
Send
(
this
->
bufferBuilder
.
GetBufferPointer
(),
this
->
bufferBuilder
.
GetSize
());
this
->
Send
(
this
->
bufferBuilder
.
GetBufferPointer
(),
this
->
bufferBuilder
.
GetSize
());
this
->
bufferBuilder
.
Reset
();
this
->
bufferBuilder
.
Clear
();
}
}
bool
ChannelSocket
::
CallbackRead
()
bool
ChannelSocket
::
CallbackRead
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论