aboutsummaryrefslogtreecommitdiff
path: root/common/timer.cpp
diff options
context:
space:
mode:
authorMax Horn2004-03-27 18:30:30 +0000
committerMax Horn2004-03-27 18:30:30 +0000
commitab64ef93ec638cd094ac8f8811ec54dd16ad2346 (patch)
treeb0cb48d58e056a9f147a6dc25aead512fccf8010 /common/timer.cpp
parentc33712e3d6b41442bd65e3f51c52e278a521bb08 (diff)
downloadscummvm-rg350-ab64ef93ec638cd094ac8f8811ec54dd16ad2346.tar.gz
scummvm-rg350-ab64ef93ec638cd094ac8f8811ec54dd16ad2346.tar.bz2
scummvm-rg350-ab64ef93ec638cd094ac8f8811ec54dd16ad2346.zip
clarify OSystem specification (setTimerCallback() must be 'atomic')
svn-id: r13391
Diffstat (limited to 'common/timer.cpp')
-rw-r--r--common/timer.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/common/timer.cpp b/common/timer.cpp
index 1655a2770c..f1e09a9ff0 100644
--- a/common/timer.cpp
+++ b/common/timer.cpp
@@ -51,6 +51,9 @@ Timer::Timer(OSystem *system) :
}
Timer::~Timer() {
+ // Remove the timer callback.
+ // Note: backends *must* gurantee that after this method call returns,
+ // the handler is not in use anymore; else race condtions could occurs.
_system->setTimerCallback(0, 0);
{
@@ -62,15 +65,6 @@ Timer::~Timer() {
}
}
-
- // FIXME: There is still a potential race condition here, depending on how
- // the system backend implements setTimerCallback: If timers are done using
- // threads, and if setTimerCallback does *not* gurantee that after it terminates
- // that timer thread is not run anymore, we are fine. However, if the timer
- // is still running in parallel to this destructor, then it might be that
- // it is still waiting for the _mutex. So, again depending on the backend,
- // we might end up unlocking the mutex then immediately deleting it, while
- // the timer thread is about to lock it.
_system->deleteMutex(_mutex);
}