Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
6a844150
提交
6a844150
authored
3月 15, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
blocking opt
上级
612f16b8
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
4 行删除
+29
-4
Cargo.toml
roboplc-derive/Cargo.toml
+1
-1
lib.rs
roboplc-derive/src/lib.rs
+28
-3
没有找到文件。
roboplc-derive/Cargo.toml
浏览文件 @
6a844150
[package]
[package]
name
=
"roboplc-derive"
name
=
"roboplc-derive"
version
=
"0.1.
2
"
version
=
"0.1.
3
"
edition
=
"2021"
edition
=
"2021"
authors
=
[
"Serhij S. <div@altertech.com>"
]
authors
=
[
"Serhij S. <div@altertech.com>"
]
license
=
"Apache-2.0"
license
=
"Apache-2.0"
...
...
roboplc-derive/src/lib.rs
浏览文件 @
6a844150
...
@@ -222,15 +222,19 @@ fn parse_delivery_policy(s: Option<&str>) -> proc_macro2::TokenStream {
...
@@ -222,15 +222,19 @@ fn parse_delivery_policy(s: Option<&str>) -> proc_macro2::TokenStream {
///
///
/// * `stack_size` - Specifies the stack size for the worker
/// * `stack_size` - Specifies the stack size for the worker
///
///
/// * `blocking` - Specifies if the worker is blocking. The value can be `true` or `false`. A hint
/// for task supervisors that the worker blocks the thread (e.g. listens to a socket or has got a
/// big interval in the main loop, does not return any useful result and should not be joined)
///
/// * `scheduling` - Specifies the scheduling policy for the worker. The value can be one of the:
/// * `scheduling` - Specifies the scheduling policy for the worker. The value can be one of the:
/// `roundrobin`, `fifo`, `idle`, `batch`, `deadline`, `normal`. If not specified, the default is
/// `roundrobin`, `fifo`, `idle`, `batch`, `deadline`, `normal`. If not specified, the default is
/// `normal`
.
/// `normal`
///
///
/// * `priority` - Specifies the real-time priority for the worker, higher is better. If specified,
/// * `priority` - Specifies the real-time priority for the worker, higher is better. If specified,
/// the scheduling policy must be `fifo`, `roundrobin` or `deadline`
.
/// the scheduling policy must be `fifo`, `roundrobin` or `deadline`
///
///
/// * `cpu` - Specifies the CPU affinity for the worker. The value can be a single CPU number or a
/// * `cpu` - Specifies the CPU affinity for the worker. The value can be a single CPU number or a
/// range of CPUs separated by a dash. The value can be a quoted string or an integer
.
/// range of CPUs separated by a dash. The value can be a quoted string or an integer
///
///
/// Example:
/// Example:
///
///
...
@@ -265,6 +269,7 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
...
@@ -265,6 +269,7 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
let
mut
scheduling
=
None
;
let
mut
scheduling
=
None
;
let
mut
priority
=
None
;
let
mut
priority
=
None
;
let
mut
cpus
=
Vec
::
new
();
let
mut
cpus
=
Vec
::
new
();
let
mut
blocking
=
false
;
for
attr
in
input
.attrs
{
for
attr
in
input
.attrs
{
if
attr
.path
.is_ident
(
"worker_opts"
)
{
if
attr
.path
.is_ident
(
"worker_opts"
)
{
...
@@ -281,12 +286,22 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
...
@@ -281,12 +286,22 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
}
else
if
path
.is_ident
(
"stack_size"
)
{
}
else
if
path
.is_ident
(
"stack_size"
)
{
if
let
Lit
::
Int
(
lit_int
)
=
lit
{
if
let
Lit
::
Int
(
lit_int
)
=
lit
{
stack_size
=
Some
(
lit_int
.base10_parse
::
<
usize
>
()
.unwrap
());
stack_size
=
Some
(
lit_int
.base10_parse
::
<
usize
>
()
.unwrap
());
}
else
{
panic!
(
"worker stack size must be usize"
);
}
}
else
if
path
.is_ident
(
"blocking"
)
{
if
let
Lit
::
Bool
(
lit_bool
)
=
lit
{
blocking
=
lit_bool
.value
;
}
else
{
panic!
(
"worker blocking must be bool"
);
}
}
}
else
if
path
.is_ident
(
"scheduling"
)
{
}
else
if
path
.is_ident
(
"scheduling"
)
{
scheduling
=
Some
(
parse_scheduling
(
lit
));
scheduling
=
Some
(
parse_scheduling
(
lit
));
}
else
if
path
.is_ident
(
"priority"
)
{
}
else
if
path
.is_ident
(
"priority"
)
{
if
let
Lit
::
Int
(
lit_int
)
=
lit
{
if
let
Lit
::
Int
(
lit_int
)
=
lit
{
priority
=
Some
(
lit_int
.base10_parse
::
<
i32
>
()
.unwrap
());
priority
=
Some
(
lit_int
.base10_parse
::
<
i32
>
()
.unwrap
());
}
else
{
panic!
(
"worker priority must be i32"
);
}
}
}
else
if
path
.is_ident
(
"cpu"
)
{
}
else
if
path
.is_ident
(
"cpu"
)
{
if
let
Lit
::
Int
(
lit_int
)
=
lit
{
if
let
Lit
::
Int
(
lit_int
)
=
lit
{
...
@@ -373,6 +388,15 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
...
@@ -373,6 +388,15 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
}
else
{
}
else
{
quote!
{}
quote!
{}
};
};
let
blocking_impl
=
if
blocking
{
quote!
{
fn
worker_is_blocking
(
&
self
)
->
bool
{
true
}
}
}
else
{
quote!
{}
};
let
expanded
=
quote!
{
let
expanded
=
quote!
{
impl
::
roboplc
::
controller
::
WorkerOptions
for
#
name
{
impl
::
roboplc
::
controller
::
WorkerOptions
for
#
name
{
fn
worker_name
(
&
self
)
->
&
str
{
fn
worker_name
(
&
self
)
->
&
str
{
...
@@ -383,6 +407,7 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
...
@@ -383,6 +407,7 @@ pub fn worker_opts_derive(input: TokenStream) -> TokenStream {
#
scheduling_impl
#
scheduling_impl
#
priority_impl
#
priority_impl
#
cpus_impl
#
cpus_impl
#
blocking_impl
}
}
};
};
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论