fix
This commit is contained in:
parent
b9476e9db1
commit
1e1a03c104
2 changed files with 4 additions and 24 deletions
|
@ -12,28 +12,13 @@ void BoundedBuffer::push(string item){
|
||||||
full->V();//increment the number of full slots now.
|
full->V();//increment the number of full slots now.
|
||||||
}
|
}
|
||||||
|
|
||||||
string BoundedBuffer::pop(){
|
string BoundedBuffer::pop(){
|
||||||
<<<<<<< HEAD
|
|
||||||
if(data.size() > 0){
|
|
||||||
full->P();
|
|
||||||
mutex->P();
|
|
||||||
string item = data.back();
|
|
||||||
data.pop_back();
|
|
||||||
mutex->V();
|
|
||||||
empty->V();
|
|
||||||
return item;
|
|
||||||
}else{
|
|
||||||
return "quit";
|
|
||||||
}
|
|
||||||
|
|
||||||
=======
|
|
||||||
full->P();
|
full->P();
|
||||||
mutex->P();
|
mutex->P();
|
||||||
string item = data.back();
|
string item = data.back();
|
||||||
data.pop_back();
|
data.pop_back();
|
||||||
mutex->V();
|
mutex->V();
|
||||||
empty->V();
|
empty->V();
|
||||||
return item;
|
return item;
|
||||||
>>>>>>> 05aaecdb17812b161db2168b80a19fc2c783800b
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,7 @@ public:
|
||||||
|
|
||||||
BoundedBuffer(int b){
|
BoundedBuffer(int b){
|
||||||
empty = new Semaphore(b);
|
empty = new Semaphore(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void set_empty(int e){empty = new Semaphore(e);}
|
|
||||||
=======
|
|
||||||
void set_empty(int e){
|
void set_empty(int e){
|
||||||
delete empty;
|
delete empty;
|
||||||
empty = new Semaphore(e);
|
empty = new Semaphore(e);
|
||||||
|
@ -36,8 +32,7 @@ public:
|
||||||
|
|
||||||
bool is_empty() {
|
bool is_empty() {
|
||||||
return (data.size() == 0);
|
return (data.size() == 0);
|
||||||
}
|
}
|
||||||
>>>>>>> 05aaecdb17812b161db2168b80a19fc2c783800b
|
|
||||||
|
|
||||||
void push(string item);
|
void push(string item);
|
||||||
|
|
||||||
|
|
Reference in a new issue