Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
ReadMailReallyFast
code
Commits
7c3ce8e4
Verified
Commit
7c3ce8e4
authored
6 years ago
by
Benny Baumann
Browse files
Options
Downloads
Patches
Plain Diff
add: Allow to sync UI interactions on any callable
parent
3d1ba2aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/app/rmrf.cpp
+9
-1
9 additions, 1 deletion
src/app/rmrf.cpp
src/app/rmrf.ldflags
+1
-1
1 addition, 1 deletion
src/app/rmrf.ldflags
src/ui/View.cpp
+1
-1
1 addition, 1 deletion
src/ui/View.cpp
src/ui/View.h
+22
-1
22 additions, 1 deletion
src/ui/View.h
with
33 additions
and
4 deletions
src/app/rmrf.cpp
+
9
−
1
View file @
7c3ce8e4
#include
<iostream>
#include
"ui/View.h"
int
main
()
{
auto
ui_handle
=
std
::
make_shared
<
rmrf
::
ui
::
display
>
();
using
rmrf
::
ui
::
display
;
auto
h_nc
=
std
::
make_shared
<
display
>
();
h_nc
->
sync
([](
const
display
::
ptr_type
&
)
{
std
::
cout
<<
"Hello World!
\n
"
<<
std
::
flush
;
});
return
0
;
}
This diff is collapsed.
Click to expand it.
src/app/rmrf.ldflags
+
1
−
1
View file @
7c3ce8e4
-lncursesw
-lncursesw
-pthread
This diff is collapsed.
Click to expand it.
src/ui/View.cpp
+
1
−
1
View file @
7c3ce8e4
...
...
@@ -8,7 +8,7 @@
namespace
rmrf
::
ui
{
display
::
display
()
{
display
::
display
()
:
m
{}
{
initscr
();
}
...
...
This diff is collapsed.
Click to expand it.
src/ui/View.h
+
22
−
1
View file @
7c3ce8e4
#pragma once
#include
<functional>
#include
<memory>
#include
<shared_mutex>
namespace
rmrf
::
ui
{
struct
display
:
std
::
enable_shared_from_this
<
display
>
{
class
display
:
public
std
::
enable_shared_from_this
<
display
>
{
public:
typedef
display
self_type
;
typedef
std
::
shared_ptr
<
self_type
>
ptr_type
;
private:
typedef
std
::
shared_mutex
mutex_type
;
typedef
std
::
lock_guard
<
mutex_type
>
lock_type
;
mutable
mutex_type
m
;
public:
display
();
~
display
();
public:
template
<
typename
F
,
typename
...
Args
>
decltype
(
auto
)
sync
(
F
&&
f
,
Args
&&
...
args
)
{
lock_type
lock
(
m
);
return
std
::
forward
<
F
>
(
f
)(
shared_from_this
(),
std
::
forward
<
Args
>
(
args
)...);
}
};
}
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