@@ -1188,78 +1188,11 @@ static void *run_http_server(void *) {
11881188 return nullptr ;
11891189}
11901190
1191- #if 0
1192- static void watch_dir () {
1193- PgArena arena = pg_arena_make_from_virtual_mem (4 * PG_KiB );
1194- PgArenaAllocator arena_allocator = pg_make_arena_allocator (& arena );
1195- PgAllocator * allocator = pg_arena_allocator_as_allocator (& arena_allocator );
1196-
1197- PG_RESULT (PgAio , PgError ) res_aio = pg_aio_init ();
1198- PgAio aio = PG_UNWRAP (res_aio );
1199-
1200- PgError err = pg_aio_register_watch_directory (
1201- & aio , PG_S ("." ),
1202- PG_WALK_DIRECTORY_KIND_FILE | PG_WALK_DIRECTORY_KIND_DIRECTORY ,
1203- allocator );
1204- PG_ASSERT (0 == err );
1205-
1206- for (;;) {
1207- PG_RESULT (PgAioEvent , PgError )
1208- res_wait = pg_aio_fs_wait_one (aio , PG_NONE (u32 ), allocator );
1209- PgAioEvent event = PG_UNWRAP (res_wait );
1210-
1211- PgString ext = pg_file_extension (event .name );
1212- if (pg_string_eq (ext , PG_S ("md" ))) {
1213- fprintf (stderr , "file modified: %.*s %d\n" , (i32 )event .name .len ,
1214- event .name .data , event .kind );
1215- }
1216- }
1217- }
1218- #endif
1219-
12201191int main () {
12211192 PgArena arena = pg_arena_make_from_virtual_mem (120 * PG_MiB );
12221193 PgArenaAllocator arena_allocator = pg_make_arena_allocator (& arena );
12231194 PgAllocator * allocator = pg_arena_allocator_as_allocator (& arena_allocator );
12241195
1225- #if 0
1226- {
1227- PgThreadResult res_thread = pg_thread_create (run_http_server , nullptr );
1228- PG_ASSERT (!res_thread .err );
1229- }
1230- #endif
1231-
1232- #if 0
1233- {
1234- PG_RESULT (PgFileDescriptor ) res_fs_init = pg_aio_fs_init ();
1235- PG_ASSERT (0 == res_fs_init .err );
1236- PgFileDescriptor fs_manager = res_fs_init .res ;
1237-
1238- PG_RESULT (PgFileDescriptor ) res_fd = pg_aio_fs_register_interest (
1239- fs_manager , PG_S ("." ),
1240- PG_AIO_EVENT_KIND_FILE_MODIFIED | PG_AIO_EVENT_KIND_FILE_CREATED );
1241- PG_ASSERT (0 == res_fd .err );
1242- PgFileDescriptor fs_fd = res_fd .res ;
1243- PG_ASSERT (0 != fs_fd .fd );
1244-
1245- PG_RESULT (PgFileDescriptor ) res_init = pg_aio_init ();
1246- PG_ASSERT (0 == res_init .err );
1247- PgFileDescriptor manager = res_init .res ;
1248-
1249- PgError err = pg_aio_register_interest (manager , fs_manager ,
1250- PG_AIO_EVENT_KIND_READABLE );
1251- PG_ASSERT (0 == err );
1252-
1253- for (u64 i = 0 ; i < 10 ; i ++ ) {
1254- PgAioEventResult res_fs_wait =
1255- pg_aio_fs_wait_one (manager , (Pgu32Option ){0 }, allocator );
1256- PG_ASSERT (0 == res_fs_wait .err );
1257- PgAioEvent ev = res_fs_wait .res ;
1258- printf ("%u %.*s\n" , ev .kind , (i32 )ev .name .len , ev .name .data );
1259- }
1260- }
1261- #endif
1262-
12631196 PG_RESULT (PgString , PgError )
12641197 res_header = pg_file_read_full_from_path (PG_S ("header.html" ), allocator );
12651198 PgString header = PG_UNWRAP (res_header );
@@ -1279,8 +1212,4 @@ int main() {
12791212
12801213 printf ("generated %" PRIu64 " articles (arena use=%" PRIu64 ")\n" ,
12811214 articles .len , pg_arena_mem_use (arena ));
1282-
1283- #if 0
1284- watch_dir ();
1285- #endif
12861215}
0 commit comments