Skip to content

Commit

Permalink
Fix threadsafe event removal.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Aug 7, 2013
1 parent 0dc6bab commit 7dfee29
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Core/CoreTiming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,10 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
}
}
if (!tsFirst)
{
tsLast = NULL;
return result;
}

Event *prev = tsFirst;
Event *ptr = prev->next;
Expand All @@ -348,6 +351,8 @@ s64 UnscheduleThreadsafeEvent(int event_type, u64 userdata)
result = ptr->time - globalTimer;

prev->next = ptr->next;
if (ptr == tsLast)
tsLast = prev;
FreeTsEvent(ptr);
ptr = prev->next;
}
Expand Down Expand Up @@ -439,6 +444,7 @@ void RemoveThreadsafeEvent(int event_type)
}
if (!tsFirst)
{
tsLast = NULL;
return;
}
Event *prev = tsFirst;
Expand All @@ -448,6 +454,8 @@ void RemoveThreadsafeEvent(int event_type)
if (ptr->type == event_type)
{
prev->next = ptr->next;
if (ptr == tsLast)
tsLast = prev;
FreeTsEvent(ptr);
ptr = prev->next;
}
Expand All @@ -460,7 +468,7 @@ void RemoveThreadsafeEvent(int event_type)
}

void RemoveAllEvents(int event_type)
{
{
RemoveThreadsafeEvent(event_type);
RemoveEvent(event_type);
}
Expand Down Expand Up @@ -491,7 +499,7 @@ void MoveEvents()
Common::AtomicStoreRelease(hasTsEvents, 0);

std::lock_guard<std::recursive_mutex> lk(externalEventSection);
// Move events from async queue into main queue
// Move events from async queue into main queue
while (tsFirst)
{
Event *next = tsFirst->next;
Expand Down

0 comments on commit 7dfee29

Please sign in to comment.