loop: spa_loop_invoke -> spa_loop_locked where possible

When we simply need to change some state for the code executed in the
loop, we can use locked() instead of invoke(). This is more efficient
and avoids some context switches in the normal case.
This commit is contained in:
Wim Taymans 2025-05-30 11:59:35 +02:00
parent b943c31fd8
commit c45d667934
29 changed files with 75 additions and 75 deletions

View file

@ -87,7 +87,7 @@ bool client_detach(struct client *client)
if (server->wait_clients > 0 && --server->wait_clients == 0) {
int mask = server->source->mask;
SPA_FLAG_SET(mask, SPA_IO_IN);
pw_loop_update_io(impl->loop, server->source, mask);
pw_loop_update_io(impl->main_loop, server->source, mask);
}
client->server = NULL;
@ -112,7 +112,7 @@ void client_disconnect(struct client *client)
pw_map_for_each(&client->streams, client_free_stream, client);
if (client->source) {
pw_loop_destroy_source(impl->loop, client->source);
pw_loop_destroy_source(impl->main_loop, client->source);
client->source = NULL;
}
@ -207,7 +207,7 @@ int client_queue_message(struct client *client, struct message *msg)
uint32_t mask = client->source->mask;
if (!SPA_FLAG_IS_SET(mask, SPA_IO_OUT)) {
SPA_FLAG_SET(mask, SPA_IO_OUT);
pw_loop_update_io(impl->loop, client->source, mask);
pw_loop_update_io(impl->main_loop, client->source, mask);
}
client->new_msg_since_last_flush = true;
@ -278,7 +278,7 @@ int client_flush_messages(struct client *client)
if (SPA_FLAG_IS_SET(mask, SPA_IO_OUT)) {
SPA_FLAG_CLEAR(mask, SPA_IO_OUT);
pw_loop_update_io(client->impl->loop, client->source, mask);
pw_loop_update_io(client->impl->main_loop, client->source, mask);
}
} else {
if (res != -EAGAIN && res != -EWOULDBLOCK)