The ReadWriteLock class now has an Initialize() method to initialize the

object after creation. This enables the Inode constructor to set a better
name for the lock.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3363 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2003-05-28 01:12:38 +00:00
parent 24d6529a93
commit 1d9fd63d3a
+33 -12
View File
@@ -149,15 +149,17 @@ class Locker {
#ifdef FAST_LOCK #ifdef FAST_LOCK
class ReadWriteLock { class ReadWriteLock {
public: public:
ReadWriteLock(const char *name = "bfs r/w lock") ReadWriteLock(const char *name)
:
fWriteLock()
{
Initialize(name);
}
ReadWriteLock()
: :
fSemaphore(create_sem(0, name)),
fCount(MAX_READERS),
fWriteLock() fWriteLock()
{ {
#ifndef USER
set_sem_owner(fSemaphore, B_SYSTEM_TEAM);
#endif
} }
~ReadWriteLock() ~ReadWriteLock()
@@ -165,6 +167,16 @@ class ReadWriteLock {
delete_sem(fSemaphore); delete_sem(fSemaphore);
} }
status_t Initialize(const char *name = "bfs r/w lock")
{
fSemaphore = create_sem(0, name);
fCount = MAX_READERS;
#ifndef USER
set_sem_owner(fSemaphore, B_SYSTEM_TEAM);
#endif
return fSemaphore;
}
status_t InitCheck() status_t InitCheck()
{ {
if (fSemaphore < B_OK) if (fSemaphore < B_OK)
@@ -226,13 +238,13 @@ class ReadWriteLock {
#else // FAST_LOCK #else // FAST_LOCK
class ReadWriteLock { class ReadWriteLock {
public: public:
ReadWriteLock(const char *name = "bfs r/w lock") ReadWriteLock(const char *name)
: {
fSemaphore(create_sem(MAX_READERS, name)) Initialize(name);
}
ReadWriteLock()
{ {
#ifndef USER
set_sem_owner(fSemaphore, B_SYSTEM_TEAM);
#endif
} }
~ReadWriteLock() ~ReadWriteLock()
@@ -240,6 +252,15 @@ class ReadWriteLock {
delete_sem(fSemaphore); delete_sem(fSemaphore);
} }
status_t Initialize(const char *name = "bfs r/w lock")
{
fSemaphore = create_sem(MAX_READERS, name);
#ifndef USER
set_sem_owner(fSemaphore, B_SYSTEM_TEAM);
#endif
return fSemaphore;
}
status_t InitCheck() status_t InitCheck()
{ {
if (fSemaphore < B_OK) if (fSemaphore < B_OK)