Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
UERANSIM
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
UERANSIM
Commits
afdcc051
Commit
afdcc051
authored
Feb 13, 2021
by
aligungr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NTS pause capability
parent
06f2f969
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
2 deletions
+44
-2
src/utils/nts.cpp
src/utils/nts.cpp
+29
-1
src/utils/nts.hpp
src/utils/nts.hpp
+15
-1
No files found.
src/utils/nts.cpp
View file @
afdcc051
...
...
@@ -10,6 +10,7 @@
#include "common.hpp"
#define WAIT_TIME_IF_NO_TIMER 500
#define PAUSE_POLLING_PERIOD 150
static
NtsMessage
*
TimerExpiredMessage
(
TimerInfo
*
timerInfo
)
{
...
...
@@ -204,7 +205,17 @@ void NtsTask::start()
{
if
(
this
->
isQuiting
)
break
;
this
->
onLoop
();
if
(
pauseReqCount
>
0
)
{
utils
::
Sleep
(
PAUSE_POLLING_PERIOD
);
pauseConfirmed
=
true
;
}
else
{
pauseConfirmed
=
false
;
this
->
onLoop
();
}
}
}};
}
...
...
@@ -233,3 +244,20 @@ void NtsTask::quit()
onQuit
();
}
void
NtsTask
::
requestPause
()
{
if
(
++
pauseReqCount
<
0
)
throw
std
::
runtime_error
(
"NTS pause overflow"
);
}
void
NtsTask
::
requestUnpause
()
{
if
(
--
pauseReqCount
<
0
)
throw
std
::
runtime_error
(
"NTS un-pause underflow"
);
}
bool
NtsTask
::
isPauseConfirmed
()
{
return
pauseConfirmed
;
}
src/utils/nts.hpp
View file @
afdcc051
...
...
@@ -112,7 +112,9 @@ class NtsTask
TimerBase
timerBase
{};
std
::
mutex
mutex
{};
std
::
condition_variable
cv
{};
std
::
atomic
<
bool
>
isQuiting
{};
std
::
atomic_bool
isQuiting
{};
std
::
atomic_int
pauseReqCount
{};
std
::
atomic_bool
pauseConfirmed
{};
std
::
thread
thread
;
public:
...
...
@@ -163,4 +165,16 @@ class NtsTask
// - Always call this function before destroying the task.
// - Calling quit() before calling start() is undefined behaviour.
void
quit
();
// - NTS task begin to be paused. The pause request is confirmed after the next loop() call.
// - If the task quits immediately and loop() never called again, this pause request will never be confirmed.
// - This should not be used if the task is quiting or quited.
void
requestPause
();
// - NTS task begin to be un-paused. The un-pause request is confirmed after the next loop() call.
// - This should not be used if the task is quiting or quited.
void
requestUnpause
();
// - Returns true iff pause was requested and now is confirmed.
bool
isPauseConfirmed
();
};
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment