mirror of https://github.com/mgba-emu/mgba.git
Core: Implement mLockstepUser for mCoreThread
This commit is contained in:
parent
3180d432e5
commit
36c1a8cfbc
|
@ -61,6 +61,17 @@ struct mLockstepUser {
|
||||||
void (*playerIdChanged)(struct mLockstepUser*, int id);
|
void (*playerIdChanged)(struct mLockstepUser*, int id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef DISABLE_THREADING
|
||||||
|
struct mCoreThread;
|
||||||
|
struct mLockstepThreadUser {
|
||||||
|
struct mLockstepUser d;
|
||||||
|
|
||||||
|
struct mCoreThread* thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
void mLockstepThreadUserInit(struct mLockstepThreadUser* lockstep, struct mCoreThread* thread);
|
||||||
|
#endif
|
||||||
|
|
||||||
CXX_GUARD_END
|
CXX_GUARD_END
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
/* Copyright (c) 2013-2016 Jeffrey Pfau
|
/* Copyright (c) 2013-2024 Jeffrey Pfau
|
||||||
*
|
*
|
||||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
#include <mgba/core/lockstep.h>
|
#include <mgba/core/lockstep.h>
|
||||||
|
|
||||||
|
#ifndef DISABLE_THREADING
|
||||||
|
#include <mgba/core/thread.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void mLockstepInit(struct mLockstep* lockstep) {
|
void mLockstepInit(struct mLockstep* lockstep) {
|
||||||
lockstep->attached = 0;
|
lockstep->attached = 0;
|
||||||
lockstep->transferActive = 0;
|
lockstep->transferActive = 0;
|
||||||
|
@ -19,4 +23,21 @@ void mLockstepDeinit(struct mLockstep* lockstep) {
|
||||||
UNUSED(lockstep);
|
UNUSED(lockstep);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Migrate nodes
|
#ifndef DISABLE_THREADING
|
||||||
|
static void mLockstepThreadUserSleep(struct mLockstepUser* user) {
|
||||||
|
struct mLockstepThreadUser* lockstep = (struct mLockstepThreadUser*) user;
|
||||||
|
mCoreThreadWaitFromThread(lockstep->thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mLockstepThreadUserWake(struct mLockstepUser* user) {
|
||||||
|
struct mLockstepThreadUser* lockstep = (struct mLockstepThreadUser*) user;
|
||||||
|
mCoreThreadStopWaiting(lockstep->thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mLockstepThreadUserInit(struct mLockstepThreadUser* lockstep, struct mCoreThread* thread) {
|
||||||
|
memset(lockstep, 0, sizeof(*lockstep));
|
||||||
|
lockstep->d.sleep = mLockstepThreadUserSleep;
|
||||||
|
lockstep->d.wake = mLockstepThreadUserWake;
|
||||||
|
lockstep->thread = thread;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue