summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2023-01-28 20:12:17 +0000
committerJelle Raaijmakers <jelle@gmta.nl>2023-01-28 22:41:36 +0100
commit108ea2b9216178446c4a22da6897e78a901eed3f (patch)
tree5de971509f4643e0a1a538a5dd60902a2f8ad7c1 /Userland
parent65fa7db2b5b94931c51e45478f6ab64634750466 (diff)
downloadserenity-108ea2b9216178446c4a22da6897e78a901eed3f.zip
LibCore: Remove `try_` prefix from fallible SharedCircularQueue methods
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Applications/PixelPaint/ImageProcessor.cpp6
-rw-r--r--Userland/Libraries/LibAudio/ConnectionToServer.cpp8
-rw-r--r--Userland/Libraries/LibCore/SharedCircularQueue.h18
-rw-r--r--Userland/Libraries/LibIPC/Decoder.h2
-rw-r--r--Userland/Services/AudioServer/Mixer.h4
5 files changed, 19 insertions, 19 deletions
diff --git a/Userland/Applications/PixelPaint/ImageProcessor.cpp b/Userland/Applications/PixelPaint/ImageProcessor.cpp
index 9aed3d3fa2..d6d970430b 100644
--- a/Userland/Applications/PixelPaint/ImageProcessor.cpp
+++ b/Userland/Applications/PixelPaint/ImageProcessor.cpp
@@ -27,10 +27,10 @@ void FilterApplicationCommand::execute()
static Singleton<ImageProcessor> s_image_processor;
ImageProcessor::ImageProcessor()
- : m_command_queue(MUST(Queue::try_create()))
+ : m_command_queue(MUST(Queue::create()))
, m_processor_thread(Threading::Thread::construct([this]() {
while (true) {
- if (auto next_command = m_command_queue.try_dequeue(); !next_command.is_error()) {
+ if (auto next_command = m_command_queue.dequeue(); !next_command.is_error()) {
next_command.value()->execute();
} else {
Threading::MutexLocker locker { m_wakeup_mutex };
@@ -51,7 +51,7 @@ ImageProcessor* ImageProcessor::the()
ErrorOr<void> ImageProcessor::enqueue_command(NonnullRefPtr<ImageProcessingCommand> command)
{
- if (auto queue_status = m_command_queue.try_enqueue(move(command)); queue_status.is_error())
+ if (auto queue_status = m_command_queue.enqueue(move(command)); queue_status.is_error())
return ENOSPC;
if (!m_processor_thread->is_started()) {
diff --git a/Userland/Libraries/LibAudio/ConnectionToServer.cpp b/Userland/Libraries/LibAudio/ConnectionToServer.cpp
index 2703c26dc0..795a4a0211 100644
--- a/Userland/Libraries/LibAudio/ConnectionToServer.cpp
+++ b/Userland/Libraries/LibAudio/ConnectionToServer.cpp
@@ -22,7 +22,7 @@ namespace Audio {
ConnectionToServer::ConnectionToServer(NonnullOwnPtr<Core::Stream::LocalSocket> socket)
: IPC::ConnectionToServer<AudioClientEndpoint, AudioServerEndpoint>(*this, move(socket))
- , m_buffer(make<AudioQueue>(MUST(AudioQueue::try_create())))
+ , m_buffer(make<AudioQueue>(MUST(AudioQueue::create())))
, m_user_queue(make<UserSampleQueue>())
, m_background_audio_enqueuer(Threading::Thread::construct([this]() {
// All the background thread does is run an event loop.
@@ -105,7 +105,7 @@ void ConnectionToServer::custom_event(Core::CustomEvent&)
m_user_queue->discard_samples(available_samples);
// FIXME: Could we receive interrupts in a good non-IPC way instead?
- auto result = m_buffer->try_blocking_enqueue(next_chunk, [this]() {
+ auto result = m_buffer->blocking_enqueue(next_chunk, [this]() {
nanosleep(&m_good_sleep_time, nullptr);
});
if (result.is_error())
@@ -115,12 +115,12 @@ void ConnectionToServer::custom_event(Core::CustomEvent&)
ErrorOr<void, AudioQueue::QueueStatus> ConnectionToServer::realtime_enqueue(Array<Sample, AUDIO_BUFFER_SIZE> samples)
{
- return m_buffer->try_enqueue(samples);
+ return m_buffer->enqueue(samples);
}
ErrorOr<void> ConnectionToServer::blocking_realtime_enqueue(Array<Sample, AUDIO_BUFFER_SIZE> samples, Function<void()> wait_function)
{
- return m_buffer->try_blocking_enqueue(samples, move(wait_function));
+ return m_buffer->blocking_enqueue(samples, move(wait_function));
}
unsigned ConnectionToServer::total_played_samples() const
diff --git a/Userland/Libraries/LibCore/SharedCircularQueue.h b/Userland/Libraries/LibCore/SharedCircularQueue.h
index b6be60b165..b7ba276a39 100644
--- a/Userland/Libraries/LibCore/SharedCircularQueue.h
+++ b/Userland/Libraries/LibCore/SharedCircularQueue.h
@@ -62,16 +62,16 @@ public:
SharedSingleProducerCircularQueue& operator=(SharedSingleProducerCircularQueue&& queue) = default;
// Allocates a new circular queue in shared memory.
- static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> try_create()
+ static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> create()
{
auto fd = TRY(System::anon_create(sizeof(SharedMemorySPCQ), O_CLOEXEC));
- return try_create_internal(fd, true);
+ return create_internal(fd, true);
}
// Uses an existing circular queue from given shared memory.
- static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> try_create(int fd)
+ static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> create(int fd)
{
- return try_create_internal(fd, false);
+ return create_internal(fd, false);
}
constexpr size_t size() const { return Size; }
@@ -90,7 +90,7 @@ public:
ALWAYS_INLINE constexpr size_t weak_head() const { return m_queue->m_queue->m_head.load(AK::MemoryOrder::memory_order_relaxed); }
ALWAYS_INLINE constexpr size_t weak_tail() const { return m_queue->m_queue->m_tail.load(AK::MemoryOrder::memory_order_relaxed); }
- ErrorOr<void, QueueStatus> try_enqueue(ValueType to_insert)
+ ErrorOr<void, QueueStatus> enqueue(ValueType to_insert)
{
VERIFY(!m_queue.is_null());
if (!can_enqueue())
@@ -108,11 +108,11 @@ public:
}
// Repeatedly try to enqueue, using the wait_function to wait if it's not possible
- ErrorOr<void> try_blocking_enqueue(ValueType to_insert, Function<void()> wait_function)
+ ErrorOr<void> blocking_enqueue(ValueType to_insert, Function<void()> wait_function)
{
ErrorOr<void, QueueStatus> result;
while (true) {
- result = try_enqueue(to_insert);
+ result = enqueue(to_insert);
if (!result.is_error())
break;
if (result.error() != QueueStatus::Full)
@@ -123,7 +123,7 @@ public:
return {};
}
- ErrorOr<ValueType, QueueStatus> try_dequeue()
+ ErrorOr<ValueType, QueueStatus> dequeue()
{
VERIFY(!m_queue.is_null());
while (true) {
@@ -198,7 +198,7 @@ private:
}
};
- static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> try_create_internal(int fd, bool is_new)
+ static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> create_internal(int fd, bool is_new)
{
auto name = DeprecatedString::formatted("SharedSingleProducerCircularQueue@{:x}", fd);
auto* raw_mapping = TRY(System::mmap(nullptr, sizeof(SharedMemorySPCQ), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0, 0, name));
diff --git a/Userland/Libraries/LibIPC/Decoder.h b/Userland/Libraries/LibIPC/Decoder.h
index 1a8a3e7aef..2bd1283576 100644
--- a/Userland/Libraries/LibIPC/Decoder.h
+++ b/Userland/Libraries/LibIPC/Decoder.h
@@ -137,7 +137,7 @@ template<Concepts::SharedSingleProducerCircularQueue T>
ErrorOr<T> decode(Decoder& decoder)
{
auto anon_file = TRY(decoder.decode<IPC::File>());
- return T::try_create(anon_file.take_fd());
+ return T::create(anon_file.take_fd());
}
template<Concepts::Optional T>
diff --git a/Userland/Services/AudioServer/Mixer.h b/Userland/Services/AudioServer/Mixer.h
index de613ec0d1..67628019b6 100644
--- a/Userland/Services/AudioServer/Mixer.h
+++ b/Userland/Services/AudioServer/Mixer.h
@@ -47,7 +47,7 @@ public:
return false;
if (m_in_chunk_location >= m_current_audio_chunk.size()) {
- auto result = m_buffer->try_dequeue();
+ auto result = m_buffer->dequeue();
if (result.is_error()) {
if (result.error() == Audio::AudioQueue::QueueStatus::Empty) {
dbgln("Audio client {} can't keep up!", m_client->client_id());
@@ -79,7 +79,7 @@ public:
{
ErrorOr<Array<Audio::Sample, Audio::AUDIO_BUFFER_SIZE>, Audio::AudioQueue::QueueStatus> result = Audio::AudioQueue::QueueStatus::Invalid;
do {
- result = m_buffer->try_dequeue();
+ result = m_buffer->dequeue();
} while (result.is_error() && result.error() != Audio::AudioQueue::QueueStatus::Empty);
}