bonefish + axeld:
* Removed the superfluous "flags" parameter from ConditionVariable::Add() that we forgot there when we moved the flags field from ConditionVariableEntry::Add() to Wait(). * Using this method was therefore not a good idea - only UnixFifo did, though. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26454 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -35,8 +35,7 @@ public:
|
|||||||
inline ConditionVariable* Variable() const { return fVariable; }
|
inline ConditionVariable* Variable() const { return fVariable; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline void AddToVariable(ConditionVariable* variable,
|
inline void AddToVariable(ConditionVariable* variable);
|
||||||
uint32 flags);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConditionVariable* fVariable;
|
ConditionVariable* fVariable;
|
||||||
@@ -60,8 +59,7 @@ public:
|
|||||||
inline void NotifyOne(bool threadsLocked = false);
|
inline void NotifyOne(bool threadsLocked = false);
|
||||||
inline void NotifyAll(bool threadsLocked = false);
|
inline void NotifyAll(bool threadsLocked = false);
|
||||||
|
|
||||||
void Add(ConditionVariableEntry* entry,
|
void Add(ConditionVariableEntry* entry);
|
||||||
uint32 flags = 0);
|
|
||||||
|
|
||||||
const void* Object() const { return fObject; }
|
const void* Object() const { return fObject; }
|
||||||
|
|
||||||
|
|||||||
@@ -447,10 +447,11 @@ UnixFifo::_Read(UnixRequest& request, bigtime_t timeout)
|
|||||||
while (fReaders.Head() != &request
|
while (fReaders.Head() != &request
|
||||||
&& !(IsReadShutdown() && fBuffer.Readable() == 0)) {
|
&& !(IsReadShutdown() && fBuffer.Readable() == 0)) {
|
||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fReadCondition.Add(&entry, B_CAN_INTERRUPT);
|
fReadCondition.Add(&entry);
|
||||||
|
|
||||||
mutex_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT | B_CAN_INTERRUPT,
|
||||||
|
timeout);
|
||||||
mutex_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
@@ -473,10 +474,11 @@ UnixFifo::_Read(UnixRequest& request, bigtime_t timeout)
|
|||||||
while (fBuffer.Readable() == 0
|
while (fBuffer.Readable() == 0
|
||||||
&& !IsReadShutdown() && !IsWriteShutdown()) {
|
&& !IsReadShutdown() && !IsWriteShutdown()) {
|
||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fReadCondition.Add(&entry, B_CAN_INTERRUPT);
|
fReadCondition.Add(&entry);
|
||||||
|
|
||||||
mutex_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT | B_CAN_INTERRUPT,
|
||||||
|
timeout);
|
||||||
mutex_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
@@ -503,10 +505,11 @@ UnixFifo::_Write(UnixRequest& request, bigtime_t timeout)
|
|||||||
// wait for the request to reach the front of the queue
|
// wait for the request to reach the front of the queue
|
||||||
while (fWriters.Head() != &request && !IsWriteShutdown()) {
|
while (fWriters.Head() != &request && !IsWriteShutdown()) {
|
||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fWriteCondition.Add(&entry, B_CAN_INTERRUPT);
|
fWriteCondition.Add(&entry);
|
||||||
|
|
||||||
mutex_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
status_t error = entry.Wait(B_ABSOLUTE_TIMEOUT | B_CAN_INTERRUPT,
|
||||||
|
timeout);
|
||||||
mutex_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
@@ -529,19 +532,19 @@ UnixFifo::_Write(UnixRequest& request, bigtime_t timeout)
|
|||||||
while (error == B_OK && fBuffer.Writable() == 0 && !IsWriteShutdown()
|
while (error == B_OK && fBuffer.Writable() == 0 && !IsWriteShutdown()
|
||||||
&& !IsReadShutdown()) {
|
&& !IsReadShutdown()) {
|
||||||
ConditionVariableEntry entry;
|
ConditionVariableEntry entry;
|
||||||
fWriteCondition.Add(&entry, B_CAN_INTERRUPT);
|
fWriteCondition.Add(&entry);
|
||||||
|
|
||||||
mutex_unlock(&fLock);
|
mutex_unlock(&fLock);
|
||||||
error = entry.Wait(B_ABSOLUTE_TIMEOUT, timeout);
|
error = entry.Wait(B_ABSOLUTE_TIMEOUT | B_CAN_INTERRUPT, timeout);
|
||||||
mutex_lock(&fLock);
|
mutex_lock(&fLock);
|
||||||
|
|
||||||
if (error != B_OK)
|
if (error != B_OK)
|
||||||
RETURN_ERROR(error);
|
RETURN_ERROR(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsWriteShutdown())
|
if (IsWriteShutdown())
|
||||||
RETURN_ERROR(UNIX_FIFO_SHUTDOWN);
|
RETURN_ERROR(UNIX_FIFO_SHUTDOWN);
|
||||||
|
|
||||||
if (IsReadShutdown())
|
if (IsReadShutdown())
|
||||||
RETURN_ERROR(EPIPE);
|
RETURN_ERROR(EPIPE);
|
||||||
|
|
||||||
|
|||||||
@@ -171,17 +171,14 @@ ConditionVariableEntry::Wait(const void* object, uint32 flags,
|
|||||||
|
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
ConditionVariableEntry::AddToVariable(ConditionVariable* variable, uint32 flags)
|
ConditionVariableEntry::AddToVariable(ConditionVariable* variable)
|
||||||
{
|
{
|
||||||
fThread = thread_get_current_thread();
|
fThread = thread_get_current_thread();
|
||||||
|
|
||||||
thread_prepare_to_block(fThread, flags,
|
|
||||||
THREAD_BLOCK_TYPE_CONDITION_VARIABLE, fVariable);
|
|
||||||
|
|
||||||
// add to the variable
|
|
||||||
InterruptsSpinLocker _(sConditionVariablesLock);
|
InterruptsSpinLocker _(sConditionVariablesLock);
|
||||||
|
|
||||||
fVariable = variable;
|
fVariable = variable;
|
||||||
|
fWaitStatus = STATUS_ADDED;
|
||||||
fVariable->fEntries.Add(this);
|
fVariable->fEntries.Add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,9 +243,9 @@ ConditionVariable::Unpublish(bool threadsLocked)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ConditionVariable::Add(ConditionVariableEntry* entry, uint32 flags)
|
ConditionVariable::Add(ConditionVariableEntry* entry)
|
||||||
{
|
{
|
||||||
entry->AddToVariable(this, flags);
|
entry->AddToVariable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user