Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
I3csstatus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
I3csstatus
Commits
8ad9e862
Commit
8ad9e862
authored
2 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Wrappers: Cache
parent
6763a956
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Wrappers.cs
+37
-0
37 additions, 0 deletions
Wrappers.cs
sample.conf
+5
-0
5 additions, 0 deletions
sample.conf
with
42 additions
and
0 deletions
Wrappers.cs
+
37
−
0
View file @
8ad9e862
...
...
@@ -68,6 +68,9 @@ abstract partial class StatusBar
}
}
if
(
section
.
Contains
(
"_cache"
))
module
=
new
WrapperCache
(
module
,
section
.
Mandatory
(
"_cache"
).
AsMs
());
module
.
Init
(
parrent
,
section
);
return
module
;
}
...
...
@@ -145,3 +148,37 @@ class WrapperExec: ModuleWrapper
}
}).
ToArray
();
}
class
WrapperCache
:
ModuleWrapper
{
IEnumerable
<
Block
>
data
;
long
?
dataTime_ms
;
long
maxOld_ms
;
bool
wantRedraw
=
false
;
public
WrapperCache
(
Module
_child
,
long
_maxOld_ms
):
base
(
_child
)
{
maxOld_ms
=
_maxOld_ms
;
}
override
public
IEnumerable
<
Block
>
Get
()
{
lock
(
this
)
if
(
wantRedraw
)
{
data
=
null
;
dataTime_ms
=
null
;
}
child
.
Get
();
if
(
dataTime_ms
==
null
||
dataTime_ms
+
maxOld_ms
<=
Environment
.
TickCount64
)
{
dataTime_ms
=
Environment
.
TickCount64
;
data
=
child
.
Get
();
}
return
data
;
}
override
public
void
Schedule
(
int
in_ms
)
{
lock
(
this
)
wantRedraw
=
true
;
parent
.
Schedule
(
in_ms
);
}
}
This diff is collapsed.
Click to expand it.
sample.conf
+
5
−
0
View file @
8ad9e862
...
...
@@ -311,6 +311,11 @@ _exec right super shift = osdc "Super+Shift+Right pressed"
# <string>
# Command to run
_
cache
=
10
# <time>
# Fetch data from module only once per this time.
# Note that visible data couldn't be more than (_cache + refresh) old.
# Parsers:
# ========
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment