Added Condition Variables to thread library
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@383 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -95,3 +95,5 @@ The bugs reported but not yet verified:
|
|||||||
|
|
||||||
- "Got a segfault too, on cvs version compiled today (2002/12/05), when activating Sun Device over
|
- "Got a segfault too, on cvs version compiled today (2002/12/05), when activating Sun Device over
|
||||||
the Chmmr homeworld. Worked fine on 0.1 alpha."
|
the Chmmr homeworld. Worked fine on 0.1 alpha."
|
||||||
|
|
||||||
|
- Unconfirmed report of lander cargo upgrade rendering as weapon upgrade
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
0.2:
|
0.2:
|
||||||
|
- Thread library now includes condition variables
|
||||||
|
- Shofixti dialogue fixed to subtitles, by BlckKnght
|
||||||
- Crash during loading from orbit fixed, from PhracturedBlue
|
- Crash during loading from orbit fixed, from PhracturedBlue
|
||||||
- Starmap issue when orbiting earth fixed, from PhracturedBlue
|
- Starmap issue when orbiting earth fixed, from PhracturedBlue
|
||||||
- Oscilloscope is now implemented (OpenAL)
|
- Oscilloscope is now implemented (OpenAL)
|
||||||
|
|||||||
@@ -83,7 +83,6 @@ extern Thread CreateThreadAux (ThreadFunction func, void *data,
|
|||||||
# define CreateThread(func, data, stackSize, name) \
|
# define CreateThread(func, data, stackSize, name) \
|
||||||
CreateThreadAux ((func), (data), (stackSize))
|
CreateThreadAux ((func), (data), (stackSize))
|
||||||
#endif /* !defined(THREAD_NAMES) */
|
#endif /* !defined(THREAD_NAMES) */
|
||||||
extern void KillThread (Thread thread);
|
|
||||||
extern void SleepThread (TimePeriod timePeriod);
|
extern void SleepThread (TimePeriod timePeriod);
|
||||||
extern void SleepThreadUntil (TimeCount wakeTime);
|
extern void SleepThreadUntil (TimeCount wakeTime);
|
||||||
extern void TaskSwitch (void);
|
extern void TaskSwitch (void);
|
||||||
@@ -106,6 +105,12 @@ extern void DestroyMutex (Mutex sem);
|
|||||||
extern int LockMutex (Mutex sem);
|
extern int LockMutex (Mutex sem);
|
||||||
extern void UnlockMutex (Mutex sem);
|
extern void UnlockMutex (Mutex sem);
|
||||||
|
|
||||||
|
typedef void *CondVar;
|
||||||
|
extern CondVar CreateCondVar (void);
|
||||||
|
extern void DestroyCondVar (CondVar);
|
||||||
|
extern void WaitCondVar (CondVar);
|
||||||
|
extern void SignalCondVar (CondVar);
|
||||||
|
extern void BroadcastCondVar (CondVar);
|
||||||
|
|
||||||
#endif /* _THREADLIB_H */
|
#endif /* _THREADLIB_H */
|
||||||
|
|
||||||
|
|||||||
@@ -66,3 +66,15 @@ SDLWrapper_TaskSwitch (void) {
|
|||||||
SDL_Delay (1);
|
SDL_Delay (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SDLWrapper_WaitCondVar (CondVar cv) {
|
||||||
|
int result;
|
||||||
|
Mutex temp = CreateMutex ();
|
||||||
|
LockMutex (temp);
|
||||||
|
result = SDL_CondWait (cv, temp);
|
||||||
|
UnlockMutex (temp);
|
||||||
|
DestroyMutex (temp);
|
||||||
|
if (result != 0) {
|
||||||
|
fprintf (stderr, "Error result from SDL_CondWait: %d\n", result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -77,5 +77,18 @@ typedef SDL_mutex *NativeMutex;
|
|||||||
#define NativeUnlockMutex(mutex) \
|
#define NativeUnlockMutex(mutex) \
|
||||||
SDL_mutexV ((mutex))
|
SDL_mutexV ((mutex))
|
||||||
|
|
||||||
|
typedef SDL_cond *NativeCondVar;
|
||||||
|
#define NativeCreateCondVar() \
|
||||||
|
SDL_CreateCond ()
|
||||||
|
#define NativeDestroyCondVar(condvar) \
|
||||||
|
SDL_DestroyCond((condvar))
|
||||||
|
#define NativeWaitCondVar(condvar) \
|
||||||
|
SDLWrapper_WaitCondVar((condvar))
|
||||||
|
#define NativeSignalCondVar(condvar) \
|
||||||
|
SDL_CondSignal((condvar))
|
||||||
|
#define NativeBroadcastCondVar(condvar) \
|
||||||
|
SDL_CondBroadcast((condvar))
|
||||||
|
|
||||||
|
|
||||||
#endif /* _SDLTHREAD_H */
|
#endif /* _SDLTHREAD_H */
|
||||||
|
|
||||||
|
|||||||
@@ -353,4 +353,27 @@ UnlockMutex (Mutex sem)
|
|||||||
NativeUnlockMutex ((NativeMutex) sem);
|
NativeUnlockMutex ((NativeMutex) sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CondVar
|
||||||
|
CreateCondVar ()
|
||||||
|
{
|
||||||
|
return NativeCreateCondVar ();
|
||||||
|
}
|
||||||
|
void DestroyCondVar (CondVar cv)
|
||||||
|
{
|
||||||
|
NativeDestroyCondVar (cv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WaitCondVar (CondVar cv)
|
||||||
|
{
|
||||||
|
NativeWaitCondVar (cv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SignalCondVar (CondVar cv)
|
||||||
|
{
|
||||||
|
NativeSignalCondVar (cv);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BroadcastCondVar (CondVar cv)
|
||||||
|
{
|
||||||
|
NativeBroadcastCondVar (cv);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user