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
c4d0547a
Commit
c4d0547a
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
scheduled_executor: make cancel/isCancelled non-blocking
Change-Id: Icddfa964f7980af5915b110745cb922adc10dba4
parent
ff5ed9d3
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/jamidht/jamiaccount.cpp
+7
-7
7 additions, 7 deletions
src/jamidht/jamiaccount.cpp
src/scheduled_executor.h
+10
-4
10 additions, 4 deletions
src/scheduled_executor.h
with
17 additions
and
11 deletions
src/jamidht/jamiaccount.cpp
+
7
−
7
View file @
c4d0547a
...
...
@@ -304,7 +304,7 @@ JamiAccount::~JamiAccount()
{
shutdownConnections
();
if
(
eventHandler
)
{
eventHandler
->
cancel
();
eventHandler
->
destroy
();
eventHandler
.
reset
();
}
if
(
peerDiscovery_
){
...
...
@@ -3091,17 +3091,17 @@ JamiAccount::getLastMessages(const uint64_t& base_timestamp)
void
JamiAccount
::
checkPendingCallsTask
()
{
bool
hasHandler
=
eventHandler
and
not
eventHandler
->
isCancelled
()
;
if
(
not
pendingCalls_
.
empty
()
and
not
hasHandler
)
{
eventH
andler
=
Manager
::
instance
().
scheduler
().
scheduleAtFixedRate
([
w
=
weak
()]
{
decltype
(
eventHandler
)
handler
;
if
(
not
pendingCalls_
.
empty
())
{
h
andler
=
Manager
::
instance
().
scheduler
().
scheduleAtFixedRate
([
w
=
weak
()]
{
if
(
auto
this_
=
w
.
lock
())
return
this_
->
handlePendingCallList
();
return
false
;
},
std
::
chrono
::
milliseconds
(
10
));
}
else
if
(
pendingCalls_
.
empty
()
and
hasHandler
)
{
eventHandler
->
cancel
();
eventHandler
.
reset
();
}
std
::
swap
(
handler
,
eventHandler
);
if
(
handler
)
handler
->
cancel
();
}
void
...
...
This diff is collapsed.
Click to expand it.
src/scheduled_executor.h
+
10
−
4
View file @
c4d0547a
...
...
@@ -68,22 +68,28 @@ public:
RepeatedTask
(
RepeatedJob
&&
j
)
:
job_
(
std
::
move
(
j
))
{}
bool
run
()
{
std
::
lock_guard
<
std
::
mutex
>
l
(
lock_
);
if
(
job_
and
not
job_
())
if
(
cancel_
.
load
()
or
(
job_
and
not
job_
()))
{
cancel_
.
store
(
true
);
job_
=
{};
}
return
(
bool
)
job_
;
}
void
cancel
()
{
cancel_
.
store
(
true
);
}
void
destroy
()
{
cancel
();
std
::
lock_guard
<
std
::
mutex
>
l
(
lock_
);
job_
=
{};
}
bool
isCancelled
()
const
{
std
::
lock_guard
<
std
::
mutex
>
l
(
lock_
);
return
!
job_
;
return
cancel_
.
load
();
}
private
:
NON_COPYABLE
(
RepeatedTask
);
RepeatedJob
job_
;
mutable
std
::
mutex
lock_
;
RepeatedJob
job_
;
std
::
atomic_bool
cancel_
{
false
};
};
class
ScheduledExecutor
{
...
...
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