#include <synchconsole.h>
Public Methods | |
| SynchConsole (char *, char *) | |
| ~SynchConsole () | |
| void | WriteDone () |
| void | ReadAvail () |
| void | WriteLine (char *, int) |
| int | ReadLine (char *, int) |
Private Attributes | |
| Lock * | inputMutex |
| Lock * | outputMutex |
| Semaphore * | inputAvailable |
| Semaphore * | outputDone |
| Console * | console |
|
||||||||||||
|
Definition at line 13 of file synchconsole.cc. References ASSERT, console, inputAvailable, inputMutex, NULL, outputDone, outputMutex, SynchReadAvail, SynchWriteDone, and VoidFunctionPtr.
00014 {
00015 inputMutex = new Lock("synchronized console input mutex");
00016 ASSERT(inputMutex != NULL);
00017 inputAvailable = new Semaphore("synchronized console input semaphore",0);
00018 ASSERT(inputAvailable != NULL);
00019 outputMutex = new Lock("synchronized console output mutex");
00020 ASSERT(outputMutex != NULL);
00021 outputDone = new Semaphore("synchronized console output semaphore", 0);
00022 ASSERT(outputDone != NULL);
00023
00024 console = new Console(readFile, writeFile,
00025 (VoidFunctionPtr)SynchReadAvail, (VoidFunctionPtr)SynchWriteDone,(int) this);
00026 }
|
|
|
Definition at line 28 of file synchconsole.cc. References console, inputAvailable, inputMutex, NULL, outputDone, and outputMutex.
00029 {
00030 delete inputMutex;
00031 inputMutex = NULL;
00032 delete outputMutex;
00033 outputMutex = NULL;
00034 delete inputAvailable;
00035 inputAvailable = NULL;
00036 delete outputDone;
00037 outputDone = NULL;
00038 delete console;
00039 console = 0;
00040 }
|
|
|
Definition at line 6 of file synchconsole.cc. References inputAvailable, and Semaphore::V. Referenced by SynchReadAvail.
00006 { inputAvailable->V();}
|
|
||||||||||||
|
Definition at line 56 of file synchconsole.cc. References Lock::Acquire, console, DEBUG, Console::GetChar, inputAvailable, inputMutex, Semaphore::P, and Lock::Release.
00057 {
00058 char c = 0;
00059 int num_read = 0;
00060 inputMutex->Acquire();
00061 while (c != '\n' && num_read < size) {
00062 inputAvailable->P();
00063 c = console->GetChar();
00064 *line = c;
00065 line++; num_read++;
00066 }
00067 inputMutex->Release();
00068 DEBUG('r', "Read the %d character string %s into buffer of size %d\n",num_read, line-num_read, size);
00069 return num_read;
00070 }
|
|
|
Definition at line 5 of file synchconsole.cc. References outputDone, and Semaphore::V. Referenced by SynchWriteDone.
00005 { outputDone->V();}
|
|
||||||||||||
|
Definition at line 43 of file synchconsole.cc. References Lock::Acquire, console, outputDone, outputMutex, Semaphore::P, Console::PutChar, and Lock::Release.
00044 {
00045
00046 outputMutex->Acquire();
00047 while (size --) {
00048 console->PutChar(*line);
00049 line++;
00050 outputDone->P();
00051 }
00052 outputMutex->Release();
00053 }
|
|
|
Definition at line 24 of file synchconsole.h. Referenced by ReadLine, SynchConsole, WriteLine, and ~SynchConsole. |
|
|
Definition at line 22 of file synchconsole.h. Referenced by ReadAvail, ReadLine, SynchConsole, and ~SynchConsole. |
|
|
Definition at line 20 of file synchconsole.h. Referenced by ReadLine, SynchConsole, and ~SynchConsole. |
|
|
Definition at line 23 of file synchconsole.h. Referenced by SynchConsole, WriteDone, WriteLine, and ~SynchConsole. |
|
|
Definition at line 21 of file synchconsole.h. Referenced by SynchConsole, WriteLine, and ~SynchConsole. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002