From 2091bd588f0160dabe77bb4241deed7bd88d606f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 2 Jul 2003 16:38:29 +0000 Subject: [PATCH] Replaced usage of List template class by the kernel utils Vector. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3811 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../core/disk_device_manager/RWLocker.cpp | 15 +++++++----- .../core/disk_device_manager/RWLocker.h | 24 ++++++++++--------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/kernel/core/disk_device_manager/RWLocker.cpp b/src/kernel/core/disk_device_manager/RWLocker.cpp index 0d2e315bf0..3517e4387c 100644 --- a/src/kernel/core/disk_device_manager/RWLocker.cpp +++ b/src/kernel/core/disk_device_manager/RWLocker.cpp @@ -435,8 +435,8 @@ RWLocker::_WriteLock(bigtime_t timeout) int32 RWLocker::_AddReadLockInfo(ReadLockInfo* info) { - int32 index = fReadLockInfos.CountItems(); - fReadLockInfos.AddItem(info, index); + int32 index = fReadLockInfos.Count(); + fReadLockInfos.Insert(info, index); return index; } @@ -457,8 +457,9 @@ RWLocker::_NewReadLockInfo(thread_id thread, int32 count) void RWLocker::_DeleteReadLockInfo(int32 index) { - if (ReadLockInfo* info = fReadLockInfos.ItemAt(index)) { - fReadLockInfos.RemoveItem(index); + if (index >= 0 && index < fReadLockInfos.Count()) { + ReadLockInfo* info = fReadLockInfos.ElementAt(index); + fReadLockInfos.Erase(index); delete info; } } @@ -467,14 +468,16 @@ RWLocker::_DeleteReadLockInfo(int32 index) RWLocker::ReadLockInfo* RWLocker::_ReadLockInfoAt(int32 index) const { - return fReadLockInfos.ItemAt(index); + if (index >= 0 && index < fReadLockInfos.Count()) + return fReadLockInfos.ElementAt(index); + return NULL; } // _IndexOf int32 RWLocker::_IndexOf(thread_id thread) const { - int32 count = fReadLockInfos.CountItems(); + int32 count = fReadLockInfos.Count(); for (int32 i = 0; i < count; i++) { if (_ReadLockInfoAt(i)->reader == thread) return i; diff --git a/src/kernel/core/disk_device_manager/RWLocker.h b/src/kernel/core/disk_device_manager/RWLocker.h index ee84bfdcb7..ccaef57a48 100644 --- a/src/kernel/core/disk_device_manager/RWLocker.h +++ b/src/kernel/core/disk_device_manager/RWLocker.h @@ -70,7 +70,7 @@ #include -#include "List.h" +#include class RWLocker { public: @@ -114,16 +114,18 @@ class RWLocker { static void _ReleaseBenaphore(Benaphore& benaphore); private: - mutable Benaphore fLock; // data lock - Benaphore fMutex; // critical code mutex - Benaphore fQueue; // queueing semaphore - int32 fReaderCount; // total count... - int32 fWriterCount; // total count... - List fReadLockInfos; - thread_id fWriter; // current write lock owner - int32 fWriterWriterCount; // write lock owner count - int32 fWriterReaderCount; // writer read lock owner - // count + mutable Benaphore fLock; // data lock + Benaphore fMutex; // critical code mutex + Benaphore fQueue; // queueing semaphore + int32 fReaderCount; // total count... + int32 fWriterCount; // total count... + Vector fReadLockInfos; + thread_id fWriter; // current write lock + // owner + int32 fWriterWriterCount; // write lock owner + // count + int32 fWriterReaderCount; // writer read lock + // owner count }; #endif // RW_LOCKER_H