From 0e173d8d8d8023bab5b5d7baa5a7a763baa24adc Mon Sep 17 00:00:00 2001 From: skyjake Date: Tue, 9 Sep 2003 21:40:55 +0000 Subject: [PATCH] Renamed mutex routines to Sys_Lock and Sys_Unlock --- doomsday/Include/sys_system.h | 4 ++-- doomsday/Src/dd_input.c | 22 +++++++++++----------- doomsday/Src/net_main.c | 10 +++++----- doomsday/Src/sys_network.cpp | 11 +++++++---- doomsday/Src/sys_system.c | 8 ++++---- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/doomsday/Include/sys_system.h b/doomsday/Include/sys_system.h index b916b24dbf..78a967571b 100644 --- a/doomsday/Include/sys_system.h +++ b/doomsday/Include/sys_system.h @@ -45,7 +45,7 @@ void Sys_SuspendThread(int handle, boolean dopause); boolean Sys_GetThreadExitCode(int handle, uint *exitCode); int Sys_CreateMutex(const char *name); void Sys_DestroyMutex(int handle); -void Sys_AcquireMutex(int handle); -void Sys_ReleaseMutex(int handle); +void Sys_Lock(int handle); +void Sys_Unlock(int handle); #endif \ No newline at end of file diff --git a/doomsday/Src/dd_input.c b/doomsday/Src/dd_input.c index 91f8bc0bf1..17f9b22d7b 100644 --- a/doomsday/Src/dd_input.c +++ b/doomsday/Src/dd_input.c @@ -169,7 +169,7 @@ static char defaultShiftTable[96] = // Contains characters 32 to 127. static boolean stopInputThread = false; static int inputThreadHandle; -static int eventQueueMutex; +static int eventQueueLock; static repeater_t keyReps[MAX_DOWNKEYS]; static int oldMouseX, oldMouseY; @@ -364,7 +364,7 @@ void DD_ProcessEvents(void) // No new events will be posted until the currently queued ones // have been processed. - Sys_AcquireMutex(eventQueueMutex); + Sys_Lock(eventQueueLock); for(; eventTail != eventHead; eventTail = (++eventTail)&(MAXEVENTS-1)) { @@ -406,7 +406,7 @@ void DD_ProcessEvents(void) } // New events can be posted again. - Sys_ReleaseMutex(eventQueueMutex); + Sys_Unlock(eventQueueLock); } /* @@ -414,13 +414,13 @@ void DD_ProcessEvents(void) */ void DD_ClearEvents(void) { - Sys_AcquireMutex(eventQueueMutex); + Sys_Lock(eventQueueLock); eventHead = eventTail; eventCount = 0; // New events can be posted again. - Sys_ReleaseMutex(eventQueueMutex); + Sys_Unlock(eventQueueLock); } /* @@ -432,13 +432,13 @@ void DD_PostEvent(event_t *ev) if(eventCount == MAXEVENTS - 1) return; // Only one thread can access the queue at a time. - Sys_AcquireMutex(eventQueueMutex); + Sys_Lock(eventQueueLock); events[eventHead] = *ev; eventHead = (++eventHead) & (MAXEVENTS - 1); eventCount++; - Sys_ReleaseMutex(eventQueueMutex); + Sys_Unlock(eventQueueLock); } //=========================================================================== @@ -777,7 +777,7 @@ int DD_InputThread(void *parm) // Generate ticcmds for local players. for(i = 0; i < DDMAXPLAYERS; i++) - if(players[i].ingame && players[i].flags && DDPF_LOCAL) + if(Net_IsLocalPlayer(i)) { // Build a command for this player. P_BuildCommand(i); @@ -827,7 +827,7 @@ void DD_InitInput(void) // A mutex is used to control access to the event queue. The input // threads writes to the queue and the refresh queue reads events // from it. - eventQueueMutex = Sys_CreateMutex("EventQueueMutex"); + eventQueueLock = Sys_CreateMutex("EventQueueMutex"); DD_DefaultKeyMapping(); } @@ -839,6 +839,6 @@ void DD_ShutdownInput(void) { DD_StopInput(); - Sys_DestroyMutex(eventQueueMutex); - eventQueueMutex = 0; + Sys_DestroyMutex(eventQueueLock); + eventQueueLock = 0; } \ No newline at end of file diff --git a/doomsday/Src/net_main.c b/doomsday/Src/net_main.c index 0ab1937b33..0ab5c621a3 100644 --- a/doomsday/Src/net_main.c +++ b/doomsday/Src/net_main.c @@ -381,7 +381,7 @@ void Net_NewLocalCmd(ticcmd_t *cmd, int pNum) client_t *cl = clients + pNum; // Acquire exclusive usage on the local buffer. - Sys_AcquireMutex(cl->localCmdLock); + Sys_Lock(cl->localCmdLock); if(cl->numLocal != LOCALTICS) { @@ -389,7 +389,7 @@ void Net_NewLocalCmd(ticcmd_t *cmd, int pNum) memcpy(&cl->localCmds[TICCMD_IDX(cl->numLocal++)], cmd, TICCMD_SIZE); } - Sys_ReleaseMutex(cl->localCmdLock); + Sys_Unlock(cl->localCmdLock); } /* @@ -397,7 +397,7 @@ void Net_NewLocalCmd(ticcmd_t *cmd, int pNum) */ boolean Net_IsLocalPlayer(int pNum) { - return players[pNum].ingame && (players[pNum].flags & DDPF_LOCAL); + return players[pNum].ingame && players[pNum].flags & DDPF_LOCAL; } /* @@ -417,7 +417,7 @@ void Net_SendCommandsToServer(timespan_t time) { if(!Net_IsLocalPlayer(i)) continue; - Sys_AcquireMutex(clients[i].localCmdLock); + Sys_Lock(clients[i].localCmdLock); // The game will pack the commands into a buffer. The returned // pointer points to a buffer that contains its size and the @@ -433,7 +433,7 @@ void Net_SendCommandsToServer(timespan_t time) // The buffer is cleared. clients[i].numLocal = 0; - Sys_ReleaseMutex(clients[i].localCmdLock); + Sys_Unlock(clients[i].localCmdLock); } } diff --git a/doomsday/Src/sys_network.cpp b/doomsday/Src/sys_network.cpp index 298a1311e7..1632bfa4d6 100644 --- a/doomsday/Src/sys_network.cpp +++ b/doomsday/Src/sys_network.cpp @@ -38,6 +38,9 @@ /* * $Log$ + * Revision 1.8 2003/09/09 21:38:24 skyjake + * Renamed mutex routines to Sys_Lock and Sys_Unlock + * * Revision 1.7 2003/09/08 22:19:40 skyjake * Float timing loop, use timespan_t in tickers, style cleanup * @@ -690,7 +693,7 @@ void N_SMSReset(store_t *store) void N_PostMessage(netmessage_t *msg) { // Lock the message queue. - Sys_AcquireMutex(gMsgMutex); + Sys_Lock(gMsgMutex); // This will be the latest message. msg->next = NULL; @@ -707,7 +710,7 @@ void N_PostMessage(netmessage_t *msg) // If there is no head, this'll be the first message. if(gMsgHead == NULL) gMsgHead = msg; - Sys_ReleaseMutex(gMsgMutex); + Sys_Unlock(gMsgMutex); } /* @@ -721,7 +724,7 @@ netmessage_t* N_GetMessage(void) { if(gMsgHead == NULL) return NULL; - Sys_AcquireMutex(gMsgMutex); + Sys_Lock(gMsgMutex); // This is the message we'll return. netmessage_t *msg = gMsgHead; @@ -732,7 +735,7 @@ netmessage_t* N_GetMessage(void) // Advance the head pointer. gMsgHead = gMsgHead->next; - Sys_ReleaseMutex(gMsgMutex); + Sys_Unlock(gMsgMutex); // Identify the sender. msg->player = N_IdentifyPlayer(msg->sender); diff --git a/doomsday/Src/sys_system.c b/doomsday/Src/sys_system.c index 13802d7419..1ceba95e5e 100644 --- a/doomsday/Src/sys_system.c +++ b/doomsday/Src/sys_system.c @@ -336,10 +336,10 @@ void Sys_DestroyMutex(int handle) /* * Acquire a mutex. Blocks until ownership has been acquired. */ -void Sys_AcquireMutex(int handle) +void Sys_Lock(int mutexHandle) { // Five seconds is plenty. - if(WaitForSingleObject((HANDLE)handle, 5000) == WAIT_TIMEOUT) + if(WaitForSingleObject((HANDLE)mutexHandle, 5000) == WAIT_TIMEOUT) { // Couldn't lock it. #ifdef _DEBUG @@ -351,7 +351,7 @@ void Sys_AcquireMutex(int handle) /* * Release a mutex. */ -void Sys_ReleaseMutex(int handle) +void Sys_Unlock(int mutexHandle) { - ReleaseMutex((HANDLE)handle); + ReleaseMutex((HANDLE)mutexHandle); }