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
36dfd11f
Commit
36dfd11f
authored
Sep 5, 2019
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
manager: add shared asio::io_context
Change-Id: Iebd54e75d9f7baaa61547dd1e18100a7d88cc807
parent
331a4105
No related branches found
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
configure.ac
+2
-0
2 additions, 0 deletions
configure.ac
src/manager.cpp
+29
-0
29 additions, 0 deletions
src/manager.cpp
src/manager.h
+6
-0
6 additions, 0 deletions
src/manager.h
with
37 additions
and
0 deletions
configure.ac
+
2
−
0
View file @
36dfd11f
...
@@ -209,6 +209,8 @@ AS_IF([test "x$enable_shared" == "xyes"], [
...
@@ -209,6 +209,8 @@ AS_IF([test "x$enable_shared" == "xyes"], [
])
])
AC_MSG_RESULT([$RING_SHARED])
AC_MSG_RESULT([$RING_SHARED])
CPPFLAGS="${CPPFLAGS} -DASIO_STANDALONE"
dnl
dnl
dnl Check for the contrib directory
dnl Check for the contrib directory
dnl
dnl
...
...
This diff is collapsed.
Click to expand it.
src/manager.cpp
+
29
−
0
View file @
36dfd11f
...
@@ -83,6 +83,9 @@ using random_device = dht::crypto::random_device;
...
@@ -83,6 +83,9 @@ using random_device = dht::crypto::random_device;
#include
<opendht/thread_pool.h>
#include
<opendht/thread_pool.h>
#include
<asio/io_context.hpp>
#include
<asio/executor_work_guard.hpp>
#ifndef WIN32
#ifndef WIN32
#include
<sys/time.h>
#include
<sys/time.h>
#include
<sys/resource.h>
#include
<sys/resource.h>
...
@@ -331,6 +334,9 @@ struct Manager::ManagerPimpl
...
@@ -331,6 +334,9 @@ struct Manager::ManagerPimpl
Manager
&
base_
;
// pimpl back-pointer
Manager
&
base_
;
// pimpl back-pointer
std
::
shared_ptr
<
asio
::
io_context
>
ioContext_
;
std
::
thread
ioContextRunner_
;
/** Main scheduler */
/** Main scheduler */
ScheduledExecutor
scheduler_
;
ScheduledExecutor
scheduler_
;
...
@@ -408,6 +414,7 @@ struct Manager::ManagerPimpl
...
@@ -408,6 +414,7 @@ struct Manager::ManagerPimpl
Manager
::
ManagerPimpl
::
ManagerPimpl
(
Manager
&
base
)
Manager
::
ManagerPimpl
::
ManagerPimpl
(
Manager
&
base
)
:
base_
(
base
)
:
base_
(
base
)
,
ioContext_
(
std
::
make_shared
<
asio
::
io_context
>
())
,
toneCtrl_
(
base
.
preferences
)
,
toneCtrl_
(
base
.
preferences
)
,
currentCallMutex_
()
,
currentCallMutex_
()
,
dtmfKey_
()
,
dtmfKey_
()
...
@@ -431,6 +438,15 @@ Manager::ManagerPimpl::ManagerPimpl(Manager& base)
...
@@ -431,6 +438,15 @@ Manager::ManagerPimpl::ManagerPimpl(Manager& base)
rand_
.
seed
(
seed
);
rand_
.
seed
(
seed
);
jami
::
libav_utils
::
ring_avcodec_init
();
jami
::
libav_utils
::
ring_avcodec_init
();
ioContextRunner_
=
std
::
thread
([
context
=
ioContext_
](){
try
{
auto
work
=
asio
::
make_work_guard
(
*
context
);
context
->
run
();
}
catch
(
const
std
::
exception
&
ex
)
{
JAMI_ERR
(
"Unexpected io_context thread exception: %s"
,
ex
.
what
());
}
});
}
}
bool
bool
...
@@ -836,6 +852,13 @@ Manager::finish() noexcept
...
@@ -836,6 +852,13 @@ Manager::finish() noexcept
dht
::
ThreadPool
::
computation
().
join
();
dht
::
ThreadPool
::
computation
().
join
();
pj_shutdown
();
pj_shutdown
();
if
(
!
pimpl_
->
ioContext_
->
stopped
()){
pimpl_
->
ioContext_
->
reset
();
// allow to finish
pimpl_
->
ioContext_
->
stop
();
// make thread stop
}
if
(
pimpl_
->
ioContextRunner_
.
joinable
())
pimpl_
->
ioContextRunner_
.
join
();
}
catch
(
const
VoipLinkException
&
err
)
{
}
catch
(
const
VoipLinkException
&
err
)
{
JAMI_ERR
(
"%s"
,
err
.
what
());
JAMI_ERR
(
"%s"
,
err
.
what
());
}
}
...
@@ -1704,6 +1727,12 @@ Manager::scheduler()
...
@@ -1704,6 +1727,12 @@ Manager::scheduler()
return
pimpl_
->
scheduler_
;
return
pimpl_
->
scheduler_
;
}
}
std
::
shared_ptr
<
asio
::
io_context
>
Manager
::
ioContext
()
const
{
return
pimpl_
->
ioContext_
;
}
void
void
Manager
::
addTask
(
std
::
function
<
bool
()
>&&
task
)
Manager
::
addTask
(
std
::
function
<
bool
()
>&&
task
)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/manager.h
+
6
−
0
View file @
36dfd11f
...
@@ -44,6 +44,10 @@
...
@@ -44,6 +44,10 @@
#include
<functional>
#include
<functional>
#include
<algorithm>
#include
<algorithm>
namespace
asio
{
class
io_context
;
}
namespace
jami
{
namespace
jami
{
namespace
video
{
namespace
video
{
...
@@ -858,6 +862,8 @@ class Manager {
...
@@ -858,6 +862,8 @@ class Manager {
ScheduledExecutor
&
scheduler
();
ScheduledExecutor
&
scheduler
();
std
::
shared_ptr
<
asio
::
io_context
>
ioContext
()
const
;
void
addTask
(
std
::
function
<
bool
()
>&&
task
);
void
addTask
(
std
::
function
<
bool
()
>&&
task
);
std
::
shared_ptr
<
Task
>
scheduleTask
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
time_point
when
);
std
::
shared_ptr
<
Task
>
scheduleTask
(
std
::
function
<
void
()
>&&
task
,
std
::
chrono
::
steady_clock
::
time_point
when
);
...
...
This diff is collapsed.
Click to expand it.
Andreas Traczyk
@atraczyk
mentioned in commit
fd970d5e
·
Sep 6, 2019
mentioned in commit
fd970d5e
mentioned in commit fd970d5e2fc66f1f55e35ec9637e5ba4a8cb489e
Toggle commit list
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