LibCore: Stop obsessing about tiny OOMs in Core::Timer

Work towards #20405
This commit is contained in:
Andreas Kling 2024-04-16 20:34:01 +02:00
parent bf1c82724f
commit 1cb5385a29
Notes: sideshowbarker 2024-07-16 21:39:23 +09:00
52 changed files with 111 additions and 113 deletions

View File

@ -55,14 +55,14 @@ static constexpr CGFloat const WINDOW_HEIGHT = 300;
__weak TaskManager* weak_self = self;
m_update_timer = MUST(Core::Timer::create_repeating(1000, [weak_self] {
m_update_timer = Core::Timer::create_repeating(1000, [weak_self] {
TaskManager* strong_self = weak_self;
if (strong_self == nil) {
return;
}
[strong_self updateStatistics];
}));
});
[self setContentView:scroll_view];
[self setTitle:@"Task Manager"];

View File

@ -12,10 +12,10 @@
TEST_CASE(deferred_invoke)
{
Core::EventLoop event_loop;
auto reaper = MUST(Core::Timer::create_single_shot(250, [] {
auto reaper = Core::Timer::create_single_shot(250, [] {
warnln("I waited for the deferred_invoke to happen, but it never did!");
VERIFY_NOT_REACHED();
}));
});
Core::deferred_invoke([&event_loop] {
event_loop.quit(0);

View File

@ -43,21 +43,21 @@ TEST_CASE(file_watcher_child_events)
event_count++;
};
auto timer1 = MUST(Core::Timer::create_single_shot(500, [&] {
auto timer1 = Core::Timer::create_single_shot(500, [&] {
int rc = creat("/tmp/testfile", 0777);
EXPECT_NE(rc, -1);
}));
});
timer1->start();
auto timer2 = MUST(Core::Timer::create_single_shot(1000, [&] {
auto timer2 = Core::Timer::create_single_shot(1000, [&] {
int rc = unlink("/tmp/testfile");
EXPECT_NE(rc, -1);
}));
});
timer2->start();
auto catchall_timer = MUST(Core::Timer::create_single_shot(2000, [&] {
auto catchall_timer = Core::Timer::create_single_shot(2000, [&] {
VERIFY_NOT_REACHED();
}));
});
catchall_timer->start();
event_loop.exec();

View File

@ -241,7 +241,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
GUI::Application::the()->quit();
};
auto update_ui_timer = TRY(Core::Timer::create_single_shot(10, [&] {
auto update_ui_timer = Core::Timer::create_single_shot(10, [&] {
results_container.remove_all_children();
results_container.layout()->set_margins(app_state.visible_result_count ? GUI::Margins { 4, 0, 0, 0 } : GUI::Margins { 0 });
@ -259,7 +259,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
mark_selected_item();
Core::deferred_invoke([window] { window->resize(GUI::Desktop::the().rect().width() / 3, {}); });
}));
});
db.on_new_results = [&](auto results) {
if (results.is_empty()) {

View File

@ -15,9 +15,9 @@ TaskManagerWidget::~TaskManagerWidget() = default;
TaskManagerWidget::TaskManagerWidget()
{
m_update_timer = MUST(Core::Timer::create_repeating(1000, [this] {
m_update_timer = Core::Timer::create_repeating(1000, [this] {
this->update_statistics();
}));
});
m_update_timer->start();
m_web_view = add<WebView::OutOfProcessWebView>();

View File

@ -94,9 +94,9 @@ ErrorOr<void> ClockSettingsWidget::setup()
set_modified(true);
};
m_clock_preview_update_timer = TRY(Core::Timer::create_repeating(1000, [&]() {
m_clock_preview_update_timer = Core::Timer::create_repeating(1000, [&]() {
update_clock_preview();
}));
});
m_clock_preview_update_timer->start();
update_clock_preview();

View File

@ -271,7 +271,7 @@ void MonitorSettingsWidget::apply_settings()
box->set_icon(window()->icon());
// If after 10 seconds the user doesn't close the message box, just close it.
auto revert_timer_or_error = Core::Timer::create_repeating(1000, [&] {
auto revert_timer = Core::Timer::create_repeating(1000, [&] {
seconds_until_revert -= 1;
current_box_text_or_error = box_text();
if (current_box_text_or_error.is_error()) {
@ -285,11 +285,6 @@ void MonitorSettingsWidget::apply_settings()
box->close();
}
});
if (revert_timer_or_error.is_error()) {
GUI::MessageBox::show_error(window(), "Unable to apply changes"sv);
return;
}
auto revert_timer = revert_timer_or_error.release_value();
revert_timer->start();
// If the user selects "No", closes the window or the window gets closed by the 10 seconds timer, revert the changes.

View File

@ -37,10 +37,10 @@ ErrorOr<void> HighlightPreviewWidget::reload_cursor()
m_cursor_params = Gfx::CursorParams::parse_from_filename(cursor_path, m_cursor_bitmap->rect().center()).constrained(*m_cursor_bitmap);
// Setup cursor animation:
if (m_cursor_params.frames() > 1 && m_cursor_params.frame_ms() > 0) {
m_frame_timer = TRY(Core::Timer::create_repeating(m_cursor_params.frame_ms(), [&] {
m_frame_timer = Core::Timer::create_repeating(m_cursor_params.frame_ms(), [&] {
m_cursor_frame = (m_cursor_frame + 1) % m_cursor_params.frames();
update();
}));
});
m_frame_timer->start();
} else {
m_frame_timer = nullptr;

View File

@ -54,10 +54,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto wav_progress_window = ExportProgressWindow::construct(*window, wav_percent_written);
TRY(wav_progress_window->initialize());
auto main_widget_updater = TRY(Core::Timer::create_repeating(static_cast<int>((1 / 30.0) * 1000), [&] {
auto main_widget_updater = Core::Timer::create_repeating(static_cast<int>((1 / 30.0) * 1000), [&] {
if (window->is_active())
Core::EventLoop::current().post_event(main_widget, make<Core::CustomEvent>(0));
}));
});
main_widget_updater->start();
auto file_menu = window->add_menu("&File"_string);

View File

@ -17,7 +17,7 @@ Filter::Filter(ImageEditor* editor)
, m_update_timer(Core::Timer::create_single_shot(100, [&] {
if (on_settings_change)
on_settings_change();
}).release_value_but_fixme_should_propagate_errors())
}))
{
m_update_timer->set_active(false);
}

View File

@ -51,7 +51,7 @@ ImageEditor::ImageEditor(NonnullRefPtr<Image> image)
m_marching_ants_offset %= (marching_ant_length * 2);
if (!m_image->selection().is_empty() || m_image->selection().in_interactive_selection())
update();
}).release_value_but_fixme_should_propagate_errors();
});
m_marching_ants_timer->start();
}

View File

@ -24,7 +24,7 @@ SprayTool::SprayTool()
{
m_timer = Core::Timer::create_repeating(200, [&]() {
paint_it();
}).release_value_but_fixme_should_propagate_errors();
});
}
static double nrand()

View File

@ -44,7 +44,7 @@ TextTool::TextTool()
m_text_editor->set_font(m_selected_font);
m_cursor_blink_timer = Core::Timer::create_repeating(500, [&]() {
m_cursor_blink_state = !m_cursor_blink_state;
}).release_value_but_fixme_should_propagate_errors();
});
}
void TextTool::on_primary_color_change(Color color)

View File

@ -15,7 +15,7 @@ PlaybackManager::PlaybackManager(NonnullRefPtr<Audio::ConnectionToServer> connec
if (!m_loader)
return;
next_buffer();
}).release_value_but_fixme_should_propagate_errors();
});
}
void PlaybackManager::set_loader(NonnullRefPtr<Audio::Loader>&& loader)

View File

@ -453,9 +453,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/tmp/session/%sid/portal/config", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));
auto modified_state_check_timer = TRY(Core::Timer::create_repeating(500, [&] {
auto modified_state_check_timer = Core::Timer::create_repeating(500, [&] {
window->set_modified(tty_has_foreground_process() || shell_child_process_count() > 0);
}));
});
listener.on_confirm_close_changed = [&](bool confirm_close) {
if (confirm_close) {

View File

@ -64,14 +64,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto advice_widget = advice_window->set_main_widget<SpeechBubble>(catdog_widget);
advice_widget->set_layout<GUI::VerticalBoxLayout>(GUI::Margins {}, 0);
auto advice_timer = TRY(Core::Timer::create_single_shot(15'000, [&] {
auto advice_timer = Core::Timer::create_single_shot(15'000, [&] {
window->move_to_front();
advice_window->move_to_front();
catdog_widget->set_roaming(false);
advice_window->move_to(window->x() - advice_window->width() / 2, window->y() - advice_window->height());
advice_window->show();
advice_window->set_always_on_top();
}));
});
advice_timer->start();
advice_widget->on_dismiss = [&] {

View File

@ -57,8 +57,7 @@ DemoWizardDialog::DemoWizardDialog(GUI::Window* parent_window)
replace_page(*m_back_page);
}
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
m_page_2->on_page_enter = [&]() {
m_page_2_progress_value = 0;
m_page_2_timer->restart();

View File

@ -762,7 +762,7 @@ void Editor::create_tokens_info_timer()
m_tokens_info_timer = Core::Timer::create_repeating((int)token_info_timer_interval_ms, [this] {
on_token_info_timer_tick();
m_tokens_info_timer->stop();
}).release_value_but_fixme_should_propagate_errors();
});
m_tokens_info_timer->start();
}

View File

@ -329,7 +329,7 @@ static bool prompt_to_stop_profiling(pid_t pid, ByteString const& process_name)
clock.start();
auto update_timer = Core::Timer::create_repeating(100, [&] {
timer_label.set_text(String::formatted("{:.1} seconds", static_cast<float>(clock.elapsed()) / 1000.0f).release_value_but_fixme_should_propagate_errors());
}).release_value_but_fixme_should_propagate_errors();
});
update_timer->start();
auto& stop_button = widget->add<GUI::Button>("Stop"_string);

View File

@ -26,7 +26,7 @@ Game::Game()
m_delay_timer = Core::Timer::create_single_shot(0, [this] {
dbgln_if(HEARTS_DEBUG, "Continuing game after delay...");
advance_game();
}).release_value_but_fixme_should_propagate_errors();
});
constexpr int card_overlap = 20;
constexpr int outer_border_size = 15;
@ -151,7 +151,7 @@ void Game::show_score_card(bool game_over)
if (!m_players[0].is_human) {
close_timer = Core::Timer::create_single_shot(2000, [&] {
score_dialog->close();
}).release_value_but_fixme_should_propagate_errors();
});
close_timer->start();
}
@ -232,7 +232,7 @@ void Game::start_animation(Vector<NonnullRefPtr<Card>> cards, Gfx::IntPoint end,
m_animation_delay_timer = Core::Timer::create_single_shot(initial_delay_ms, [&] {
m_animation_playing = true;
start_timer(10);
}).release_value_but_fixme_should_propagate_errors();
});
m_animation_delay_timer->start();
}

View File

@ -22,7 +22,7 @@
namespace MasterWord {
WordGame::WordGame()
: m_clear_message_timer(Core::Timer::create_single_shot(5000, [this] { clear_message(); }).release_value_but_fixme_should_propagate_errors())
: m_clear_message_timer(Core::Timer::create_single_shot(5000, [this] { clear_message(); }))
{
read_words();
m_num_letters = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5);

View File

@ -140,8 +140,7 @@ void Field::initialize()
++m_time_elapsed;
m_time_label.set_text(human_readable_digital_time(m_time_elapsed));
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
// Square with mine will be filled with background color later, i.e. red
m_mine_palette.set_color(Gfx::ColorRole::Base, Color::from_rgb(0xff4040));

View File

@ -121,10 +121,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
uint64_t seconds_elapsed = 0;
auto timer = TRY(Core::Timer::create_repeating(1000, [&]() {
auto timer = Core::Timer::create_repeating(1000, [&]() {
++seconds_elapsed;
statusbar.set_text(2, String::formatted("Time: {}", human_readable_digital_time(seconds_elapsed)).release_value_but_fixme_should_propagate_errors());
}));
});
game.on_game_start = [&]() {
seconds_elapsed = 0;

View File

@ -154,11 +154,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
uint64_t seconds_elapsed = 0;
auto timer = TRY(Core::Timer::create_repeating(1000, [&]() {
auto timer = Core::Timer::create_repeating(1000, [&]() {
++seconds_elapsed;
statusbar.set_text(2, String::formatted("Time: {}", human_readable_digital_time(seconds_elapsed)).release_value_but_fixme_should_propagate_errors());
}));
});
game.on_game_start = [&]() {
seconds_elapsed = 0;

View File

@ -21,7 +21,7 @@ ErrorOr<NonnullRefPtr<PlaybackStream>> PlaybackStreamSerenity::create(OutputStat
if (auto result = connection->try_set_self_sample_rate(sample_rate); result.is_error())
return Error::from_string_literal("Failed to set sample rate");
auto polling_timer = TRY(Core::Timer::try_create());
auto polling_timer = Core::Timer::create();
auto implementation = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PlaybackStreamSerenity(connection, move(polling_timer), move(data_request_callback))));
if (initial_state == OutputState::Playing)
connection->async_start_playback();

View File

@ -20,7 +20,7 @@ auto debounce(int timeout, TFunction function)
timer->stop();
timer->on_timeout = move(apply_function);
} else {
timer = Core::Timer::create_single_shot(timeout, move(apply_function)).release_value_but_fixme_should_propagate_errors();
timer = Core::Timer::create_single_shot(timeout, move(apply_function));
}
timer->start();
};

View File

@ -9,6 +9,25 @@
namespace Core {
NonnullRefPtr<Timer> Timer::create()
{
return adopt_ref(*new Timer);
}
NonnullRefPtr<Timer> Timer::create_repeating(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent)
{
return adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent));
}
NonnullRefPtr<Timer> Timer::create_single_shot(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent)
{
auto timer = adopt_ref(*new Timer(interval_ms, move(timeout_handler), parent));
timer->set_single_shot(true);
return timer;
}
Timer::~Timer() = default;
Timer::Timer(EventReceiver* parent)
: EventReceiver(parent)
{

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2024, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
@ -16,18 +16,11 @@ class Timer final : public EventReceiver {
C_OBJECT(Timer);
public:
static ErrorOr<NonnullRefPtr<Timer>> create_repeating(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr)
{
return adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent));
}
static ErrorOr<NonnullRefPtr<Timer>> create_single_shot(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr)
{
auto timer = TRY(adopt_nonnull_ref_or_enomem(new Timer(interval_ms, move(timeout_handler), parent)));
timer->set_single_shot(true);
return timer;
}
static NonnullRefPtr<Timer> create();
static NonnullRefPtr<Timer> create_repeating(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr);
static NonnullRefPtr<Timer> create_single_shot(int interval_ms, Function<void()>&& timeout_handler, EventReceiver* parent = nullptr);
virtual ~Timer() override = default;
virtual ~Timer() override;
void start();
void start(int interval_ms);

View File

@ -98,13 +98,13 @@ ErrorOr<NonnullRefPtr<Application>> Application::create(Main::Arguments const& a
TRY(application->m_args.try_append(arg));
}
application->m_tooltip_show_timer = TRY(Core::Timer::create_single_shot(700, [weak_application = application->make_weak_ptr<Application>()] {
application->m_tooltip_show_timer = Core::Timer::create_single_shot(700, [weak_application = application->make_weak_ptr<Application>()] {
weak_application->request_tooltip_show();
}));
});
application->m_tooltip_hide_timer = TRY(Core::Timer::create_single_shot(50, [weak_application = application->make_weak_ptr<Application>()] {
application->m_tooltip_hide_timer = Core::Timer::create_single_shot(50, [weak_application = application->make_weak_ptr<Application>()] {
weak_application->tooltip_hide_timer_did_fire();
}));
});
return application;
}

View File

@ -2476,7 +2476,7 @@ void TextEditor::set_should_autocomplete_automatically(bool value)
m_autocomplete_timer = Core::Timer::create_single_shot(m_automatic_autocomplete_delay_ms, [this] {
if (m_autocomplete_box && !m_autocomplete_box->is_visible())
try_show_autocomplete(UserRequestedAutocomplete::No);
}).release_value_but_fixme_should_propagate_errors();
});
return;
}

View File

@ -27,7 +27,7 @@ ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalS
, m_local_endpoint_magic(local_endpoint_magic)
, m_deferred_invoker(make<CoreEventLoopDeferredInvoker>())
{
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); }).release_value_but_fixme_should_propagate_errors();
m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
}
void ConnectionBase::set_deferred_invoker(NonnullOwnPtr<DeferredInvoker> deferred_invoker)

View File

@ -115,7 +115,7 @@ void TLSv12::setup_connection()
// Extend the timer, we are too slow.
m_handshake_timeout_timer->restart(m_max_wait_time_for_handshake_in_seconds * 1000);
}
}).release_value_but_fixme_should_propagate_errors();
});
auto packet = build_hello();
write_packet(packet);
write_into_socket();

View File

@ -66,7 +66,7 @@ DecoderErrorOr<NonnullOwnPtr<PlaybackManager>> PlaybackManager::create(NonnullOw
auto frame_queue = DECODER_TRY_ALLOC(VideoFrameQueue::create());
auto playback_manager = DECODER_TRY_ALLOC(try_make<PlaybackManager>(demuxer, track, move(decoder_non_null), move(frame_queue)));
playback_manager->m_state_update_timer = DECODER_TRY_ALLOC(Core::Timer::create_single_shot(0, [&self = *playback_manager] { self.timer_callback(); }));
playback_manager->m_state_update_timer = Core::Timer::create_single_shot(0, [&self = *playback_manager] { self.timer_callback(); });
playback_manager->m_decode_thread = DECODER_TRY_ALLOC(Threading::Thread::try_create([&self = *playback_manager] {
while (!self.m_stop_decoding.load())

View File

@ -3905,7 +3905,7 @@ void Document::shared_declarative_refresh_steps(StringView input, JS::GCPtr<HTML
VERIFY(navigable());
MUST(navigable()->navigate({ .url = url_record, .source_document = *this }));
}).release_value_but_fixme_should_propagate_errors();
});
// For the purposes of the previous paragraph, a refresh is said to have come due as soon as the later of the
// following two conditions occurs:
@ -4238,7 +4238,7 @@ void Document::ensure_animation_timer()
{
constexpr static auto timer_delay_ms = 1000 / 60;
if (!m_animation_driver_timer) {
m_animation_driver_timer = MUST(Core::Timer::create_repeating(timer_delay_ms, [this] {
m_animation_driver_timer = Core::Timer::create_repeating(timer_delay_ms, [this] {
bool has_animations = false;
for (auto& timeline : m_associated_animation_timelines) {
if (!timeline->associated_animations().is_empty()) {
@ -4253,7 +4253,7 @@ void Document::ensure_animation_timer()
auto* window_or_worker = dynamic_cast<HTML::WindowOrWorkerGlobalScopeMixin*>(&realm().global_object());
VERIFY(window_or_worker);
update_animations_and_send_events(window_or_worker->performance()->now());
}));
});
}
m_animation_driver_timer->start();

View File

@ -19,9 +19,9 @@ struct AnimationFrameCallbackDriver {
AnimationFrameCallbackDriver()
{
m_timer = MUST(Core::Timer::create_single_shot(16, [] {
m_timer = Core::Timer::create_single_shot(16, [] {
HTML::main_thread_event_loop().schedule();
}));
});
}
i32 add(Callback handler)

View File

@ -291,7 +291,7 @@ BrowsingContext::BrowsingContext(JS::NonnullGCPtr<Page> page)
m_cursor_blink_state = !m_cursor_blink_state;
node->paintable()->set_needs_display();
}
}).release_value_but_fixme_should_propagate_errors();
});
}
BrowsingContext::~BrowsingContext() = default;

View File

@ -292,7 +292,7 @@ bool HTMLImageElement::uses_srcset_or_picture() const
struct BatchingDispatcher {
public:
BatchingDispatcher()
: m_timer(Core::Timer::create_single_shot(1, [this] { process(); }).release_value_but_fixme_should_propagate_errors())
: m_timer(Core::Timer::create_single_shot(1, [this] { process(); }))
{
}

View File

@ -26,11 +26,11 @@ JS_DEFINE_ALLOCATOR(HTMLTextAreaElement);
HTMLTextAreaElement::HTMLTextAreaElement(DOM::Document& document, DOM::QualifiedName qualified_name)
: HTMLElement(document, move(qualified_name))
, m_input_event_timer(MUST(Core::Timer::create_single_shot(0, [weak_this = make_weak_ptr()]() {
, m_input_event_timer(Core::Timer::create_single_shot(0, [weak_this = make_weak_ptr()]() {
if (!weak_this)
return;
static_cast<HTMLTextAreaElement*>(weak_this.ptr())->queue_firing_input_event();
})))
}))
{
}

View File

@ -37,7 +37,7 @@ SessionHistoryTraversalQueue::SessionHistoryTraversalQueue()
entry->execute_steps();
m_is_task_running = false;
}
}).release_value_but_fixme_should_propagate_errors();
});
}
void SessionHistoryTraversalQueue::visit_edges(JS::Cell::Visitor& visitor)

View File

@ -26,7 +26,7 @@ Timer::Timer(JS::Object& window_or_worker_global_scope, i32 milliseconds, JS::No
{
m_timer = Core::Timer::create_single_shot(milliseconds, [this] {
m_callback->function()();
}).release_value_but_fixme_should_propagate_errors();
});
}
void Timer::visit_edges(Cell::Visitor& visitor)

View File

@ -31,7 +31,7 @@ ErrorOr<NonnullOwnPtr<AudioCodecPluginAgnostic>> AudioCodecPluginAgnostic::creat
{
auto duration = timestamp_from_samples(loader->total_samples(), loader->sample_rate());
auto update_timer = TRY(Core::Timer::try_create());
auto update_timer = Core::Timer::create();
update_timer->set_interval(update_interval);
auto plugin = TRY(adopt_nonnull_own_or_enomem(new (nothrow) AudioCodecPluginAgnostic(loader, duration, move(update_timer))));

View File

@ -18,13 +18,13 @@ ViewImplementation::ViewImplementation()
{
m_backing_store_shrink_timer = Core::Timer::create_single_shot(3000, [this] {
resize_backing_stores_if_needed(WindowResizeInProgress::No);
}).release_value_but_fixme_should_propagate_errors();
});
m_repeated_crash_timer = Core::Timer::create_single_shot(1000, [this] {
// Reset the "crashing a lot" counter after 1 second in case we just
// happen to be visiting crashy websites a lot.
this->m_crash_count = 0;
}).release_value_but_fixme_should_propagate_errors();
});
on_request_file = [this](auto const& path, auto request_id) {
auto file = Core::File::open(path, Core::File::OpenMode::Read);

View File

@ -183,8 +183,7 @@ void Mixer::request_setting_sync()
if (auto result = m_config->sync(); result.is_error())
dbgln("Failed to write audio mixer config: {}", result.error());
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
m_config_write_timer->start();
}
}

View File

@ -76,7 +76,7 @@ static Core::ConfigFile& ensure_domain_config(ByteString const& domain)
ConnectionFromClient::ConnectionFromClient(NonnullOwnPtr<Core::LocalSocket> client_socket, int client_id)
: IPC::ConnectionFromClient<ConfigClientEndpoint, ConfigServerEndpoint>(*this, move(client_socket), client_id)
, m_sync_timer(Core::Timer::create_single_shot(s_disk_sync_delay_ms, [this]() { sync_dirty_domains_to_disk(); }).release_value_but_fixme_should_propagate_errors())
, m_sync_timer(Core::Timer::create_single_shot(s_disk_sync_delay_ms, [this]() { sync_dirty_domains_to_disk(); }))
{
s_connections.set(client_id, *this);
}

View File

@ -144,8 +144,7 @@ DHCPv4Client::DHCPv4Client(Vector<ByteString> interfaces_with_dhcp_enabled)
}
m_check_timer = Core::Timer::create_repeating(
1000, [this] { try_discover_ifs(); }, this)
.release_value_but_fixme_should_propagate_errors();
1000, [this] { try_discover_ifs(); }, this);
m_check_timer->start();
@ -266,8 +265,7 @@ void DHCPv4Client::handle_ack(DHCPv4Packet const& packet, ParsedDHCPv4Options co
transaction->has_ip = false;
dhcp_discover(interface);
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
Optional<IPv4Address> gateway;
if (auto routers = options.get_many<IPv4Address>(DHCPOption::Router, 1); !routers.is_empty())
@ -294,8 +292,7 @@ void DHCPv4Client::handle_nak(DHCPv4Packet const& packet, ParsedDHCPv4Options co
[this, iface = InterfaceDescriptor { iface }] {
dhcp_discover(iface);
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
}
void DHCPv4Client::process_incoming(DHCPv4Packet const& packet)

View File

@ -217,7 +217,7 @@ decltype(auto) get_or_create_connection(auto& cache, URL::URL const& url, auto j
sockets_for_url.append(make<ConnectionType>(
socket_result.release_value(),
typename ConnectionType::QueueType {},
Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr).release_value_but_fixme_should_propagate_errors()));
Core::Timer::create_single_shot(ConnectionKeepAliveTimeMilliseconds, nullptr)));
sockets_for_url.last()->proxy = move(proxy);
did_add_new_connection = true;
}

View File

@ -56,8 +56,7 @@ Compositor::Compositor()
[this] {
compose();
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
m_compose_timer->start();
m_immediate_compose_timer = Core::Timer::create_single_shot(
@ -65,8 +64,7 @@ Compositor::Compositor()
[this] {
compose();
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
m_compose_timer->start();
init_bitmaps();
@ -1626,8 +1624,7 @@ void Compositor::start_window_stack_switch_overlay_timer()
[this] {
remove_window_stack_switch_overlays();
},
this)
.release_value_but_fixme_should_propagate_errors();
this);
m_stack_switch_overlay_timer->start();
}

View File

@ -280,7 +280,7 @@ void ConnectionFromClient::flash_menubar_menu(i32 window_id, i32 menu_id)
return;
weak_window->menubar().flash_menu(nullptr);
weak_window->frame().invalidate_menubar();
}).release_value_but_fixme_should_propagate_errors();
});
m_flashed_menu_timer->start();
} else if (m_flashed_menu_timer) {
m_flashed_menu_timer->restart();
@ -1186,7 +1186,7 @@ void ConnectionFromClient::may_have_become_unresponsive()
async_ping();
m_ping_timer = Core::Timer::create_single_shot(1000, [this] {
set_unresponsive(true);
}).release_value_but_fixme_should_propagate_errors();
});
m_ping_timer->start();
}

View File

@ -551,7 +551,7 @@ void Menu::start_activation_animation(MenuItem& item)
painter.clear_rect({ {}, animation->window->rect().size() }, Color::Transparent);
painter.blit({}, original_bitmap, item_rect, opacity, true);
animation->window->invalidate();
}).release_value_but_fixme_should_propagate_errors();
});
timer->start();
}

View File

@ -946,7 +946,7 @@ void WindowFrame::start_flash_animation()
invalidate_titlebar();
if (!--m_flash_counter)
m_flash_timer->stop();
}).release_value_but_fixme_should_propagate_errors();
});
}
m_flash_counter = 8;
m_flash_timer->start();

View File

@ -2005,9 +2005,9 @@ ErrorOr<Vector<Line::CompletionSuggestion>> Shell::complete_via_program_itself(s
true);
Vector<Line::CompletionSuggestion> suggestions;
auto timer = TRY(Core::Timer::create_single_shot(300, [&] {
auto timer = Core::Timer::create_single_shot(300, [&] {
Core::EventLoop::current().quit(1);
}));
});
timer->start();
// Restrict the process to effectively readonly access to the FS.

View File

@ -218,7 +218,7 @@ static ErrorOr<NonnullRefPtr<Core::Timer>> load_page_for_screenshot_and_exit(Cor
outln("Taking screenshot after {} seconds", screenshot_timeout);
auto timer = TRY(Core::Timer::create_single_shot(
auto timer = Core::Timer::create_single_shot(
screenshot_timeout * 1000,
[&]() {
if (auto screenshot = view.take_screenshot()) {
@ -232,7 +232,7 @@ static ErrorOr<NonnullRefPtr<Core::Timer>> load_page_for_screenshot_and_exit(Cor
}
event_loop.quit(0);
}));
});
view.load(url);
timer->start();
@ -272,10 +272,10 @@ static ErrorOr<TestResult> run_dump_test(HeadlessWebContentView& view, StringVie
Core::EventLoop loop;
bool did_timeout = false;
auto timeout_timer = TRY(Core::Timer::create_single_shot(timeout_in_milliseconds, [&] {
auto timeout_timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&] {
did_timeout = true;
loop.quit(0);
}));
});
auto url = URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)));
@ -373,10 +373,10 @@ static ErrorOr<TestResult> run_ref_test(HeadlessWebContentView& view, StringView
Core::EventLoop loop;
bool did_timeout = false;
auto timeout_timer = TRY(Core::Timer::create_single_shot(timeout_in_milliseconds, [&] {
auto timeout_timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&] {
did_timeout = true;
loop.quit(0);
}));
});
RefPtr<Gfx::Bitmap> actual_screenshot, expectation_screenshot;
view.on_load_finish = [&](auto const&) {