From 71a49db6b6eb0624d7a67a227e8d34f51d2a314a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 22 Apr 2008 21:47:54 +0000 Subject: [PATCH] Use the thread blocking functions instead of a condition variable for read request. Can probably be done for writers as well. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25111 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/fifo.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/system/kernel/fs/fifo.cpp b/src/system/kernel/fs/fifo.cpp index 690895972b..77cae4ac4b 100644 --- a/src/system/kernel/fs/fifo.cpp +++ b/src/system/kernel/fs/fifo.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -74,20 +75,23 @@ class RingBuffer { class ReadRequest : public DoublyLinkedListLinkImpl { public: + ReadRequest() + : fThread(find_thread(NULL)) + { + } + void SetUnnotified() { fNotified = false; } void Notify() { if (!fNotified) { - fWaitCondition.NotifyOne(); + thread_unblock(fThread, B_OK); fNotified = true; } } - ConditionVariable& WaitCondition() { return fWaitCondition; } - private: - ConditionVariable fWaitCondition; + thread_id fThread; bool fNotified; }; @@ -467,22 +471,15 @@ Inode::WaitForReadRequest(ReadRequest &request) { request.SetUnnotified(); - // publish the condition variable - ConditionVariable& conditionVariable = request.WaitCondition(); - conditionVariable.Publish(&request, "pipe request"); - // add the entry to wait on - ConditionVariableEntry entry; - entry.Add(&request, B_CAN_INTERRUPT); + thread_prepare_to_block(thread_get_current_thread(), B_CAN_INTERRUPT, + THREAD_BLOCK_TYPE_OTHER, "fifo read request"); // wait benaphore_unlock(&fRequestLock); - status_t status = entry.Wait(); + status_t status = thread_block(); benaphore_lock(&fRequestLock); - // unpublish the condition variable - conditionVariable.Unpublish(); - return status; }