hw4 test
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
// otherwise, read from this file
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SynchConsoleInput::SynchConsoleInput(char *inputFile)
|
||||
SynchConsoleInput::SynchConsoleInput(char* inputFile)
|
||||
{
|
||||
consoleInput = new ConsoleInput(inputFile, this);
|
||||
lock = new Lock("console in");
|
||||
@@ -30,9 +30,9 @@ SynchConsoleInput::SynchConsoleInput(char *inputFile)
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SynchConsoleInput::~SynchConsoleInput()
|
||||
{
|
||||
delete consoleInput;
|
||||
delete lock;
|
||||
{
|
||||
delete consoleInput;
|
||||
delete lock;
|
||||
delete waitFor;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ SynchConsoleInput::CallBack()
|
||||
// otherwise, read from this file
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SynchConsoleOutput::SynchConsoleOutput(char *outputFile)
|
||||
SynchConsoleOutput::SynchConsoleOutput(char* outputFile)
|
||||
{
|
||||
consoleOutput = new ConsoleOutput(outputFile, this);
|
||||
lock = new Lock("console out");
|
||||
@@ -86,9 +86,9 @@ SynchConsoleOutput::SynchConsoleOutput(char *outputFile)
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
SynchConsoleOutput::~SynchConsoleOutput()
|
||||
{
|
||||
delete consoleOutput;
|
||||
delete lock;
|
||||
{
|
||||
delete consoleOutput;
|
||||
delete lock;
|
||||
delete waitFor;
|
||||
}
|
||||
|
||||
@@ -106,13 +106,18 @@ SynchConsoleOutput::PutChar(char ch)
|
||||
lock->Release();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// SynchConsoleOutput::PutInt
|
||||
// Write a int to the console display, waiting if necessary.
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
void
|
||||
SynchConsoleOutput::PutInt(int value)
|
||||
{
|
||||
lock->Acquire();
|
||||
consoleOutput->PutInt(value);
|
||||
waitFor->P();
|
||||
lock->Release();
|
||||
lock->Acquire();
|
||||
consoleOutput->PutInt(value);
|
||||
waitFor->P();
|
||||
lock->Release();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user