Repository navigation
Expand file tree
/
Copy pathEntropyMainExample.c
More file actions
54 lines (46 loc) · 1.58 KB
/
Copy pathEntropyMainExample.c
File metadata and controls
54 lines (46 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <Core/entropy_main.h>
#include <Logging/CLogger.h>
static void will_finish(EntropyApp* app, void* userdata) {
(void)app;
(void)userdata;
ENTROPY_LOG_INFO_F("[EntropyMainExample] will_finish_launching");
}
static void did_finish(EntropyApp* app, void* userdata) {
(void)app;
(void)userdata;
ENTROPY_LOG_INFO_F("[EntropyMainExample] did_finish_launching");
// Request termination directly; no main-thread posting API
entropy_main_terminate(0);
}
static bool should_terminate(EntropyApp* app, void* userdata) {
(void)app;
(void)userdata;
// Allow termination when requested
return true;
}
static void will_terminate(EntropyApp* app, void* userdata) {
(void)app;
(void)userdata;
ENTROPY_LOG_INFO_F("[EntropyMainExample] will_terminate");
}
static void did_catch(EntropyApp* app, void* userdata) {
(void)app;
(void)userdata;
ENTROPY_LOG_WARNING_F("[EntropyMainExample] did_catch_unhandled_exception (if any)");
}
int main(void) {
EntropyMainConfig cfg = {0};
cfg.worker_threads = 0; // auto
cfg.shutdown_deadline_ms = 3000;
EntropyAppDelegateC del = {0};
del.will_finish_launching = will_finish;
del.did_finish_launching = did_finish;
del.should_terminate = should_terminate;
del.will_terminate = will_terminate;
del.did_catch_unhandled_exception = did_catch;
del.userdata = NULL;
ENTROPY_LOG_INFO_F("[EntropyMainExample] Starting entropy_main_run...");
int rc = entropy_main_run(&cfg, &del);
ENTROPY_LOG_INFO_F("[EntropyMainExample] Exited with code %d", rc);
return rc;
}