From 6d921617f9b5302a2e37d1942c62d9cbec94afe4 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Wed, 10 Apr 2019 23:57:00 +0200 Subject: [PATCH] daemon: make context_num_clients a public method So it can be used from outside daemon/gamemode.c, to e.g. implement an ClientCount property. --- daemon/gamemode.c | 6 +----- daemon/gamemode.h | 7 +++++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/daemon/gamemode.c b/daemon/gamemode.c index 71f1a78..3bb8be4 100644 --- a/daemon/gamemode.c +++ b/daemon/gamemode.c @@ -89,7 +89,6 @@ static volatile bool had_context_init = false; static GameModeClient *game_mode_client_new(pid_t pid, char *exe); static void game_mode_client_free(GameModeClient *client); static const GameModeClient *game_mode_context_has_client(GameModeContext *self, pid_t client); -static int game_mode_context_num_clients(GameModeContext *self); static void *game_mode_context_reaper(void *userdata); static void game_mode_context_enter(GameModeContext *self); static void game_mode_context_leave(GameModeContext *self); @@ -316,10 +315,7 @@ static const GameModeClient *game_mode_context_has_client(GameModeContext *self, return found; } -/** - * Helper to grab the current number of clients we know about - */ -static int game_mode_context_num_clients(GameModeContext *self) +int game_mode_context_num_clients(GameModeContext *self) { return atomic_load(&self->refcount); } diff --git a/daemon/gamemode.h b/daemon/gamemode.h index 4c469ad..7a7703c 100644 --- a/daemon/gamemode.h +++ b/daemon/gamemode.h @@ -63,6 +63,13 @@ void game_mode_context_init(GameModeContext *self); */ void game_mode_context_destroy(GameModeContext *self); +/** + * Query the number of currently registered clients. + * + * @returns The number of clients. A number > 0 means that gamemode is active. + */ +int game_mode_context_num_clients(GameModeContext *self); + /** * Register a new game client with the context *