Changeset 296 for trunk/src/kernel32/console.cpp
- Timestamp:
- Jul 12, 1999, 7:20:04 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/console.cpp
r278 r296 1 /* $Id: console.cpp,v 1. 8 1999-07-06 15:48:45phaller Exp $ */1 /* $Id: console.cpp,v 1.9 1999-07-12 17:20:03 phaller Exp $ */ 2 2 3 3 /* … … 184 184 185 185 /***************************************************************************** 186 * Name : iConsoleInputQueueLock 187 * Purpose : lock the input queue to ensure correct event sequence 188 * Parameters: 189 * Variables : 190 * Result : 191 * Remark : 192 * Status : 193 * 194 * Author : Patrick Haller [Tue, 1998/02/10 01:55] 195 *****************************************************************************/ 196 197 void static iConsoleInputQueueLock() 198 { 199 DosRequestMutexSem(ConsoleInput.hmtxInputQueue, 200 SEM_INDEFINITE_WAIT); 201 } 202 203 204 /***************************************************************************** 205 * Name : iConsoleInputQueueUnlock 206 * Purpose : unlock the input queue 207 * Parameters: 208 * Variables : 209 * Result : 210 * Remark : 211 * Status : 212 * 213 * Author : Patrick Haller [Tue, 1998/02/10 01:55] 214 *****************************************************************************/ 215 216 void static iConsoleInputQueueUnlock() 217 { 218 DosReleaseMutexSem(ConsoleInput.hmtxInputQueue); 219 } 220 221 222 /***************************************************************************** 186 223 * Name : 187 224 * Purpose : … … 225 262 } 226 263 264 265 rc = DosCreateMutexSem(NULL, 266 &ConsoleInput.hmtxInputQueue, 267 0L, 268 FALSE); 269 if (rc != NO_ERROR) /* other error ? */ 270 { 271 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */ 272 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */ 273 return (rc); /* raise error condition */ 274 } 227 275 228 276 /*************************************************************************** … … 332 380 ConsoleGlobals.Options.coordDefaultPosition.Y = 0; 333 381 ConsoleGlobals.Options.coordDefaultSize.X = 80; 334 ConsoleGlobals.Options.coordDefaultSize.Y = 35;382 ConsoleGlobals.Options.coordDefaultSize.Y = 25; 335 383 ConsoleGlobals.coordWindowSize.X = ConsoleGlobals.Options.coordDefaultSize.X; 336 384 ConsoleGlobals.coordWindowSize.Y = ConsoleGlobals.Options.coordDefaultSize.Y; … … 496 544 { 497 545 APIRET rc; 546 547 DosCloseEventSem(ConsoleGlobals.hevConsole); /* close other semaphore */ 548 DosCloseEventSem(ConsoleInput.hevInputQueue); /* close other semaphore */ 549 DosCloseMutexSem(ConsoleInput.hmtxInputQueue); /* close semaphore */ 550 498 551 499 552 WinPostMsg (ConsoleGlobals.hwndFrame, /* force thread to terminate */ … … 1308 1361 pInputRecord)); 1309 1362 #endif 1363 1364 iConsoleInputQueueLock(); 1310 1365 /* get free event */ 1311 1366 pirFree = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexFree]; 1312 1367 if (pirFree->EventType != 0x0000) 1368 { 1369 iConsoleInputQueueUnlock(); 1313 1370 return (ERROR_QUE_NO_MEMORY); /* queue is full ! */ 1314 1371 } 1315 1372 /* put event in queue */ 1373 1374 ConsoleInput.ulIndexFree++; /* update index counter */ 1375 if (ConsoleInput.ulIndexFree >= CONSOLE_INPUTQUEUESIZE) 1376 ConsoleInput.ulIndexFree = 0; 1377 1378 ConsoleInput.ulEvents++; /* increate queue event counter */ 1379 1380 iConsoleInputQueueUnlock(); 1381 1316 1382 memcpy(pirFree, /* copy data */ 1317 1383 pInputRecord, 1318 1384 sizeof (INPUT_RECORD) ); 1319 1320 ConsoleInput.ulIndexFree++; /* update index counter */1321 if (ConsoleInput.ulIndexFree >= CONSOLE_INPUTQUEUESIZE)1322 ConsoleInput.ulIndexFree = 0;1323 1324 ConsoleInput.ulEvents++; /* increate queue event counter */1325 1326 1385 /* unblock reading threads */ 1327 1386 rc = DosPostEventSem(ConsoleInput.hevInputQueue); … … 1355 1414 return (ERROR_QUE_EMPTY); /* queue is empty ! */ 1356 1415 1416 iConsoleInputQueueLock(); 1357 1417 /* get first event */ 1358 1418 pirEvent = &ConsoleInput.arrInputRecord[ConsoleInput.ulIndexEvent]; 1359 1419 if (pirEvent->EventType == 0x0000) 1420 { 1421 iConsoleInputQueueUnlock(); 1360 1422 return (ERROR_QUE_EMPTY); /* queue is empty ! */ 1423 } 1424 1425 if (ConsoleInput.ulEvents >= 0) /* decrease number of console events */ 1426 ConsoleInput.ulEvents--; 1427 1428 ConsoleInput.ulIndexEvent++; /* update index counter */ 1429 if (ConsoleInput.ulIndexEvent >= CONSOLE_INPUTQUEUESIZE) 1430 ConsoleInput.ulIndexEvent = 0; 1361 1431 1362 1432 /* put event in queue */ … … 1367 1437 pirEvent->EventType = 0x0000; /* mark event as read = free */ 1368 1438 1369 if (ConsoleInput.ulEvents >= 0) /* decrease number of console events */ 1370 ConsoleInput.ulEvents--; 1371 1372 ConsoleInput.ulIndexEvent++; /* update index counter */ 1373 if (ConsoleInput.ulIndexEvent >= CONSOLE_INPUTQUEUESIZE) 1374 ConsoleInput.ulIndexEvent = 0; 1439 iConsoleInputQueueUnlock(); 1375 1440 1376 1441 return (NO_ERROR); /* OK */
Note:
See TracChangeset
for help on using the changeset viewer.