aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Berger <j.david.berger@gmail.com>2018-04-04 09:36:10 -0600
committerJustin Berger <j.david.berger@gmail.com>2018-04-04 09:36:10 -0600
commit229a2cb44d1462200ffa14fe925cd91796e99989 (patch)
tree3bc9beacdf9f6fa4124e5ef00b1442620aece4c8 /src
parent8992810b626e58e1dd1ed61b3b41f20db60dddf4 (diff)
downloadlibsurvive-229a2cb44d1462200ffa14fe925cd91796e99989.tar.gz
libsurvive-229a2cb44d1462200ffa14fe925cd91796e99989.tar.bz2
Dramatically reduced the scope of locking
Diffstat (limited to 'src')
-rw-r--r--src/survive_api.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/survive_api.c b/src/survive_api.c
index 2aaf31a..bb1f090 100644
--- a/src/survive_api.c
+++ b/src/survive_api.c
@@ -32,18 +32,23 @@ struct SurviveAsyncContext {
};
static void pose_fn(SurviveObject *so, uint32_t timecode, SurvivePose *pose) {
+ struct SurviveAsyncContext *actx = so->ctx->user_ptr;
+ OGLockMutex(actx->poll_mutex);
survive_default_raw_pose_process(so, timecode, pose);
- struct SurviveAsyncContext* actx = so->ctx->user_ptr;
int idx = (int)so->user_ptr;
actx->objects[idx].has_update = true;
+ OGUnlockMutex(actx->poll_mutex);
}
static void lh_fn(SurviveContext *ctx, uint8_t lighthouse, SurvivePose *lighthouse_pose,
SurvivePose *object_pose) {
+ struct SurviveAsyncContext *actx = ctx->user_ptr;
+ OGLockMutex(actx->poll_mutex);
survive_default_lighthouse_pose_process(ctx, lighthouse, lighthouse_pose, object_pose);
- struct SurviveAsyncContext* actx = ctx->user_ptr;
actx->objects[lighthouse].has_update = true;
+
+ OGUnlockMutex(actx->poll_mutex);
}
struct SurviveAsyncContext *survive_async_init(int argc, char *const *argv) {
@@ -95,9 +100,7 @@ static inline void* __async_thread(void* _actx) {
struct SurviveAsyncContext* actx = _actx;
int error = 0;
while (actx->running && error == 0) {
- OGLockMutex(actx->poll_mutex);
error = survive_poll(actx->ctx);
- OGUnlockMutex(actx->poll_mutex);
}
actx->running = false;
return (void*)error;