Skip to content
This repository was archived by the owner on Aug 18, 2026. It is now read-only.

Commit 682e63b

Browse files
committed
hooks.c: use dex_scheduler_spawnv
1 parent 383afee commit 682e63b

1 file changed

Lines changed: 35 additions & 67 deletions

File tree

‎src/hooks.c‎

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,6 @@
2727
#include "hooks.h"
2828
#include "util.h"
2929

30-
BZ_DEFINE_DATA (
31-
execute_hook,
32-
ExecuteHook,
33-
{
34-
BzHook *hook;
35-
BzHookTransactionType ts_type;
36-
char *ts_appid;
37-
BzEntryGroup *group;
38-
},
39-
BZ_RELEASE_DATA (hook, g_object_unref);
40-
BZ_RELEASE_DATA (ts_appid, g_free);
41-
BZ_RELEASE_DATA (group, g_object_unref))
42-
43-
BZ_DEFINE_DATA (
44-
run_emission,
45-
RunEmission,
46-
{
47-
GListModel *hooks;
48-
BzHookSignal signal;
49-
BzHookTransactionType ts_type;
50-
char *ts_appid;
51-
BzEntryGroup *group;
52-
},
53-
BZ_RELEASE_DATA (hooks, g_object_unref);
54-
BZ_RELEASE_DATA (ts_appid, g_free);
55-
BZ_RELEASE_DATA (group, g_object_unref))
56-
5730
BZ_DEFINE_DATA (
5831
dialog,
5932
Dialog,
@@ -65,33 +38,35 @@ BZ_DEFINE_DATA (
6538
BZ_RELEASE_DATA (dialog, g_object_unref));
6639

6740
static DexFuture *
68-
execute_hook_fiber (ExecuteHookData *data);
41+
execute_hook_fiber (BzHook *hook,
42+
BzHookTransactionType ts_type,
43+
const char *ts_appid,
44+
BzEntryGroup *group);
6945

7046
static DexFuture *
71-
run_emission_fiber (RunEmissionData *data);
47+
run_emission_fiber (GListModel *hooks,
48+
BzHookSignal signal,
49+
BzHookTransactionType ts_type,
50+
const char *ts_appid,
51+
BzEntryGroup *group);
7252

7353
DexFuture *
7454
bz_execute_hook (BzHook *hook,
7555
BzHookTransactionType ts_type,
7656
const char *ts_appid,
7757
BzEntryGroup *group)
7858
{
79-
g_autoptr (ExecuteHookData) data = NULL;
80-
8159
dex_return_error_if_fail (BZ_IS_HOOK (hook));
8260

83-
data = execute_hook_data_new ();
84-
data->hook = g_object_ref (hook);
85-
data->ts_type = ts_type;
86-
data->ts_appid = bz_maybe_strdup (ts_appid);
87-
data->group = bz_object_maybe_ref (group);
88-
89-
return dex_scheduler_spawn (
61+
return dex_scheduler_spawnv (
9062
dex_scheduler_get_default (),
9163
bz_get_dex_stack_size (),
92-
(DexFiberFunc) execute_hook_fiber,
93-
execute_hook_data_ref (data),
94-
execute_hook_data_unref);
64+
G_CALLBACK (execute_hook_fiber),
65+
4,
66+
BZ_TYPE_HOOK, hook,
67+
BZ_TYPE_HOOK_TRANSACTION_TYPE, ts_type,
68+
G_TYPE_STRING, ts_appid,
69+
BZ_TYPE_ENTRY_GROUP, group);
9570
}
9671

9772
DexFuture *
@@ -101,33 +76,27 @@ bz_run_hook_emission (GListModel *hooks,
10176
const char *ts_appid,
10277
BzEntryGroup *group)
10378
{
104-
g_autoptr (RunEmissionData) data = NULL;
105-
10679
dex_return_error_if_fail (G_IS_LIST_MODEL (hooks));
10780

108-
data = run_emission_data_new ();
109-
data->hooks = g_object_ref (hooks);
110-
data->signal = signal;
111-
data->ts_type = ts_type;
112-
data->ts_appid = bz_maybe_strdup (ts_appid);
113-
data->group = bz_object_maybe_ref (group);
114-
115-
return dex_scheduler_spawn (
81+
return dex_scheduler_spawnv (
11682
dex_scheduler_get_default (),
11783
bz_get_dex_stack_size (),
118-
(DexFiberFunc) run_emission_fiber,
119-
execute_hook_data_ref (data),
120-
execute_hook_data_unref);
84+
G_CALLBACK (run_emission_fiber),
85+
5,
86+
G_TYPE_LIST_MODEL, hooks,
87+
BZ_TYPE_HOOK_SIGNAL, signal,
88+
BZ_TYPE_HOOK_TRANSACTION_TYPE, ts_type,
89+
G_TYPE_STRING, ts_appid,
90+
BZ_TYPE_ENTRY_GROUP, group);
12191
}
12292

12393
static DexFuture *
124-
execute_hook_fiber (ExecuteHookData *data)
94+
execute_hook_fiber (BzHook *hook,
95+
BzHookTransactionType ts_type,
96+
const char *ts_appid,
97+
BzEntryGroup *group)
12598
{
126-
BzHook *hook = data->hook;
127-
BzHookTransactionType ts_type = data->ts_type;
128-
char *ts_appid = data->ts_appid;
129-
BzEntryGroup *group = data->group;
130-
BzHookSignal signal = 0;
99+
BzHookSignal signal = 0;
131100
g_autoptr (GEnumClass) signal_enum_class = NULL;
132101
g_autoptr (GEnumClass) ts_type_enum_class = NULL;
133102
GEnumValue *signal_enum = NULL;
@@ -500,14 +469,13 @@ execute_hook_fiber (ExecuteHookData *data)
500469
}
501470

502471
static DexFuture *
503-
run_emission_fiber (RunEmissionData *data)
472+
run_emission_fiber (GListModel *hooks,
473+
BzHookSignal signal,
474+
BzHookTransactionType ts_type,
475+
const char *ts_appid,
476+
BzEntryGroup *group)
504477
{
505-
GListModel *hooks = data->hooks;
506-
BzHookSignal signal = data->signal;
507-
BzHookTransactionType ts_type = data->ts_type;
508-
char *ts_appid = data->ts_appid;
509-
BzEntryGroup *group = data->group;
510-
guint n_hooks = 0;
478+
guint n_hooks = 0;
511479

512480
n_hooks = g_list_model_get_n_items (hooks);
513481
for (guint i = 0; i < n_hooks; i++)

0 commit comments

Comments
 (0)