Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
2ef0a8af
Commit
2ef0a8af
authored
Dec 10, 2021
by
Olivier Dion
Committed by
Sébastien Blin
Jun 17, 2022
Browse files
Options
Downloads
Patches
Plain Diff
manager: Add execution context to scheduled executor
Change-Id: Icedfd7e3cd3765cf900e1fac26ad0106ba8a5cb3
parent
1f1e6014
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/manager.cpp
+10
-6
10 additions, 6 deletions
src/manager.cpp
src/manager.h
+18
-5
18 additions, 5 deletions
src/manager.h
with
28 additions
and
11 deletions
src/manager.cpp
+
10
−
6
View file @
2ef0a8af
...
...
@@ -1657,21 +1657,25 @@ Manager::ioContext() const
}
void
Manager
::
addTask
(
std
::
function
<
bool
()
>&&
task
)
Manager
::
addTask
(
std
::
function
<
bool
()
>&&
task
,
const
char
*
filename
,
uint32_t
linum
)
{
pimpl_
->
scheduler_
.
scheduleAtFixedRate
(
std
::
move
(
task
),
std
::
chrono
::
milliseconds
(
30
));
pimpl_
->
scheduler_
.
scheduleAtFixedRate
(
std
::
move
(
task
),
std
::
chrono
::
milliseconds
(
30
),
filename
,
linum
);
}
std
::
shared_ptr
<
Task
>
Manager
::
scheduleTask
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
time_point
when
)
Manager
::
scheduleTask
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
time_point
when
,
const
char
*
filename
,
uint32_t
linum
)
{
return
pimpl_
->
scheduler_
.
schedule
(
std
::
move
(
task
),
when
);
return
pimpl_
->
scheduler_
.
schedule
(
std
::
move
(
task
),
when
,
filename
,
linum
);
}
std
::
shared_ptr
<
Task
>
Manager
::
scheduleTaskIn
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
duration
timeout
)
Manager
::
scheduleTaskIn
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
duration
timeout
,
const
char
*
filename
,
uint32_t
linum
)
{
return
pimpl_
->
scheduler_
.
scheduleIn
(
std
::
move
(
task
),
timeout
);
return
pimpl_
->
scheduler_
.
scheduleIn
(
std
::
move
(
task
),
timeout
,
filename
,
linum
);
}
// Must be invoked periodically by a timer from the main event loop
...
...
This diff is collapsed.
Click to expand it.
src/manager.h
+
18
−
5
View file @
2ef0a8af
...
...
@@ -47,6 +47,8 @@
#include
<string>
#include
<vector>
#include
"trace-tools.h"
namespace
asio
{
class
io_context
;
}
...
...
@@ -785,11 +787,19 @@ public:
std
::
shared_ptr
<
asio
::
io_context
>
ioContext
()
const
;
void
addTask
(
std
::
function
<
bool
()
>&&
task
);
void
addTask
(
std
::
function
<
bool
()
>&&
task
,
const
char
*
filename
=
CURRENT_FILENAME
(),
uint32_t
linum
=
CURRENT_LINE
());
std
::
shared_ptr
<
Task
>
scheduleTask
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
time_point
when
);
std
::
chrono
::
steady_clock
::
time_point
when
,
const
char
*
filename
=
CURRENT_FILENAME
(),
uint32_t
linum
=
CURRENT_LINE
());
std
::
shared_ptr
<
Task
>
scheduleTaskIn
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
duration
timeout
);
std
::
chrono
::
steady_clock
::
duration
timeout
,
const
char
*
filename
=
CURRENT_FILENAME
(),
uint32_t
linum
=
CURRENT_LINE
());
std
::
map
<
std
::
string
,
std
::
string
>
getNearbyPeers
(
const
std
::
string
&
accountID
);
...
...
@@ -884,9 +894,12 @@ private:
// Helper to install a callback to be called once by the main event loop
template
<
typename
Callback
>
static
void
runOnMainThread
(
Callback
&&
cb
)
runOnMainThread
(
Callback
&&
cb
,
const
char
*
filename
=
CURRENT_FILENAME
(),
uint32_t
linum
=
CURRENT_LINE
())
{
Manager
::
instance
().
scheduler
().
run
([
cb
=
std
::
forward
<
Callback
>
(
cb
)]()
mutable
{
cb
();
});
Manager
::
instance
().
scheduler
().
run
([
cb
=
std
::
forward
<
Callback
>
(
cb
)]()
mutable
{
cb
();
},
filename
,
linum
);
}
}
// namespace jami
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