Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
05eda56e
There was an error fetching the commit references. Please try again later.
Commit
05eda56e
authored
1 year ago
by
Liam
Browse files
Options
Downloads
Patches
Plain Diff
core_timing: handle concurrent unscheduling of looping events
parent
575db041
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/core_timing.cpp
+11
-3
11 additions, 3 deletions
src/core/core_timing.cpp
src/core/core_timing.h
+4
-1
4 additions, 1 deletion
src/core/core_timing.h
with
15 additions
and
4 deletions
src/core/core_timing.cpp
+
11
−
3
View file @
05eda56e
...
@@ -159,6 +159,8 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type,
...
@@ -159,6 +159,8 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type,
for
(
auto
h
:
to_remove
)
{
for
(
auto
h
:
to_remove
)
{
event_queue
.
erase
(
h
);
event_queue
.
erase
(
h
);
}
}
event_type
->
sequence_number
++
;
}
}
// Force any in-progress events to finish
// Force any in-progress events to finish
...
@@ -202,9 +204,10 @@ std::optional<s64> CoreTiming::Advance() {
...
@@ -202,9 +204,10 @@ std::optional<s64> CoreTiming::Advance() {
const
Event
&
evt
=
event_queue
.
top
();
const
Event
&
evt
=
event_queue
.
top
();
if
(
const
auto
event_type
{
evt
.
type
.
lock
()})
{
if
(
const
auto
event_type
{
evt
.
type
.
lock
()})
{
if
(
evt
.
reschedule_time
==
0
)
{
const
auto
evt_time
=
evt
.
time
;
const
auto
evt_
time
=
evt
.
time
;
const
auto
evt_
sequence_num
=
event_type
->
sequence_number
;
if
(
evt
.
reschedule_time
==
0
)
{
event_queue
.
pop
();
event_queue
.
pop
();
basic_lock
.
unlock
();
basic_lock
.
unlock
();
...
@@ -217,10 +220,15 @@ std::optional<s64> CoreTiming::Advance() {
...
@@ -217,10 +220,15 @@ std::optional<s64> CoreTiming::Advance() {
basic_lock
.
unlock
();
basic_lock
.
unlock
();
const
auto
new_schedule_time
{
event_type
->
callback
(
const
auto
new_schedule_time
{
event_type
->
callback
(
evt
.
time
,
std
::
chrono
::
nanoseconds
{
GetGlobalTimeNs
().
count
()
-
evt
.
time
})};
evt
_
time
,
std
::
chrono
::
nanoseconds
{
GetGlobalTimeNs
().
count
()
-
evt
_
time
})};
basic_lock
.
lock
();
basic_lock
.
lock
();
if
(
evt_sequence_num
!=
event_type
->
sequence_number
)
{
// Heap handle is invalidated after external modification.
continue
;
}
const
auto
next_schedule_time
{
new_schedule_time
.
has_value
()
const
auto
next_schedule_time
{
new_schedule_time
.
has_value
()
?
new_schedule_time
.
value
().
count
()
?
new_schedule_time
.
value
().
count
()
:
evt
.
reschedule_time
};
:
evt
.
reschedule_time
};
...
...
This diff is collapsed.
Click to expand it.
src/core/core_timing.h
+
4
−
1
View file @
05eda56e
...
@@ -27,12 +27,15 @@ using TimedCallback = std::function<std::optional<std::chrono::nanoseconds>(
...
@@ -27,12 +27,15 @@ using TimedCallback = std::function<std::optional<std::chrono::nanoseconds>(
/// Contains the characteristics of a particular event.
/// Contains the characteristics of a particular event.
struct
EventType
{
struct
EventType
{
explicit
EventType
(
TimedCallback
&&
callback_
,
std
::
string
&&
name_
)
explicit
EventType
(
TimedCallback
&&
callback_
,
std
::
string
&&
name_
)
:
callback
{
std
::
move
(
callback_
)},
name
{
std
::
move
(
name_
)}
{}
:
callback
{
std
::
move
(
callback_
)},
name
{
std
::
move
(
name_
)}
,
sequence_number
{
0
}
{}
/// The event's callback function.
/// The event's callback function.
TimedCallback
callback
;
TimedCallback
callback
;
/// A pointer to the name of the event.
/// A pointer to the name of the event.
const
std
::
string
name
;
const
std
::
string
name
;
/// A monotonic sequence number, incremented when this event is
/// changed externally.
size_t
sequence_number
;
};
};
enum
class
UnscheduleEventType
{
enum
class
UnscheduleEventType
{
...
...
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