Skip to content

Commit

Permalink
Kernel: Use StringView instead of C strings in Mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Aug 29, 2021
1 parent a28cd92 commit 6ae6013
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Kernel/Locking/Mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Mutex {
public:
using Mode = LockMode;

Mutex(const char* name = nullptr)
Mutex(StringView name = {})
: m_name(name)
{
}
Expand All @@ -52,19 +52,19 @@ class Mutex {
return false;
}

[[nodiscard]] const char* name() const { return m_name; }
[[nodiscard]] StringView name() const { return m_name; }

static const char* mode_to_string(Mode mode)
static StringView mode_to_string(Mode mode)
{
switch (mode) {
case Mode::Unlocked:
return "unlocked";
return "unlocked"sv;
case Mode::Exclusive:
return "exclusive";
return "exclusive"sv;
case Mode::Shared:
return "shared";
return "shared"sv;
default:
return "invalid";
return "invalid"sv;
}
}

Expand All @@ -80,7 +80,7 @@ class Mutex {
void block(Thread&, Mode, SpinlockLocker<Spinlock<u8>>&, u32);
void unblock_waiters(Mode);

const char* m_name { nullptr };
StringView m_name;
Mode m_mode { Mode::Unlocked };

// When locked exclusively, only the thread already holding the lock can
Expand Down

0 comments on commit 6ae6013

Please sign in to comment.