Mercurial > hg > xemacs-beta
comparison src/event-stream.c @ 3263:d674024a8674
[xemacs-hg @ 2006-02-27 16:29:00 by crestani]
- Introduce a fancy asynchronous finalization strategy on C level.
- Merge the code conditioned on MC_ALLOC into the code conditioned on
NEW_GC.
- Remove the possibility to free objects manually outside garbage
collections when the new collector is enabled.
author | crestani |
---|---|
date | Mon, 27 Feb 2006 16:29:29 +0000 |
parents | facf3239ba30 |
children | 859bd40269e5 |
comparison
equal
deleted
inserted
replaced
3262:79d41cfd8e6b | 3263:d674024a8674 |
---|---|
327 #define wrap_command_builder(p) wrap_record (p, command_builder) | 327 #define wrap_command_builder(p) wrap_record (p, command_builder) |
328 #define COMMAND_BUILDERP(x) RECORDP (x, command_builder) | 328 #define COMMAND_BUILDERP(x) RECORDP (x, command_builder) |
329 #define CHECK_COMMAND_BUILDER(x) CHECK_RECORD (x, command_builder) | 329 #define CHECK_COMMAND_BUILDER(x) CHECK_RECORD (x, command_builder) |
330 #define CONCHECK_COMMAND_BUILDER(x) CONCHECK_RECORD (x, command_builder) | 330 #define CONCHECK_COMMAND_BUILDER(x) CONCHECK_RECORD (x, command_builder) |
331 | 331 |
332 #ifndef MC_ALLOC | 332 #ifndef NEW_GC |
333 static Lisp_Object Vcommand_builder_free_list; | 333 static Lisp_Object Vcommand_builder_free_list; |
334 #endif /* not MC_ALLOC */ | 334 #endif /* not NEW_GC */ |
335 | 335 |
336 static const struct memory_description command_builder_description [] = { | 336 static const struct memory_description command_builder_description [] = { |
337 { XD_LISP_OBJECT, offsetof (struct command_builder, current_events) }, | 337 { XD_LISP_OBJECT, offsetof (struct command_builder, current_events) }, |
338 { XD_LISP_OBJECT, offsetof (struct command_builder, most_current_event) }, | 338 { XD_LISP_OBJECT, offsetof (struct command_builder, most_current_event) }, |
339 { XD_LISP_OBJECT, offsetof (struct command_builder, last_non_munged_event) }, | 339 { XD_LISP_OBJECT, offsetof (struct command_builder, last_non_munged_event) }, |
387 | 387 |
388 Lisp_Object | 388 Lisp_Object |
389 allocate_command_builder (Lisp_Object console, int with_echo_buf) | 389 allocate_command_builder (Lisp_Object console, int with_echo_buf) |
390 { | 390 { |
391 Lisp_Object builder_obj = | 391 Lisp_Object builder_obj = |
392 #ifdef MC_ALLOC | 392 #ifdef NEW_GC |
393 wrap_pointer_1 (alloc_lrecord_type (struct command_builder, | 393 wrap_pointer_1 (alloc_lrecord_type (struct command_builder, |
394 &lrecord_command_builder)); | 394 &lrecord_command_builder)); |
395 #else /* not MC_ALLOC */ | 395 #else /* not NEW_GC */ |
396 alloc_managed_lcrecord (Vcommand_builder_free_list); | 396 alloc_managed_lcrecord (Vcommand_builder_free_list); |
397 #endif /* not MC_ALLOC */ | 397 #endif /* not NEW_GC */ |
398 struct command_builder *builder = XCOMMAND_BUILDER (builder_obj); | 398 struct command_builder *builder = XCOMMAND_BUILDER (builder_obj); |
399 | 399 |
400 builder->console = console; | 400 builder->console = console; |
401 reset_command_builder_event_chain (builder); | 401 reset_command_builder_event_chain (builder); |
402 if (with_echo_buf) | 402 if (with_echo_buf) |
461 if (builder->echo_buf) | 461 if (builder->echo_buf) |
462 { | 462 { |
463 xfree (builder->echo_buf, Ibyte *); | 463 xfree (builder->echo_buf, Ibyte *); |
464 builder->echo_buf = NULL; | 464 builder->echo_buf = NULL; |
465 } | 465 } |
466 #ifdef MC_ALLOC | 466 #ifdef NEW_GC |
467 free_lrecord (wrap_command_builder (builder)); | 467 free_lrecord (wrap_command_builder (builder)); |
468 #else /* not MC_ALLOC */ | 468 #else /* not NEW_GC */ |
469 free_managed_lcrecord (Vcommand_builder_free_list, | 469 free_managed_lcrecord (Vcommand_builder_free_list, |
470 wrap_command_builder (builder)); | 470 wrap_command_builder (builder)); |
471 #endif /* not MC_ALLOC */ | 471 #endif /* not NEW_GC */ |
472 } | 472 } |
473 | 473 |
474 static void | 474 static void |
475 command_builder_append_event (struct command_builder *builder, | 475 command_builder_append_event (struct command_builder *builder, |
476 Lisp_Object event) | 476 Lisp_Object event) |
1029 used to indicate an absence of a timer. */ | 1029 used to indicate an absence of a timer. */ |
1030 static int timeout_id_tick; | 1030 static int timeout_id_tick; |
1031 | 1031 |
1032 static Lisp_Object pending_timeout_list, pending_async_timeout_list; | 1032 static Lisp_Object pending_timeout_list, pending_async_timeout_list; |
1033 | 1033 |
1034 #ifndef MC_ALLOC | 1034 #ifndef NEW_GC |
1035 static Lisp_Object Vtimeout_free_list; | 1035 static Lisp_Object Vtimeout_free_list; |
1036 #endif /* not MC_ALLOC */ | 1036 #endif /* not NEW_GC */ |
1037 | 1037 |
1038 static Lisp_Object | 1038 static Lisp_Object |
1039 mark_timeout (Lisp_Object obj) | 1039 mark_timeout (Lisp_Object obj) |
1040 { | 1040 { |
1041 Lisp_Timeout *tm = XTIMEOUT (obj); | 1041 Lisp_Timeout *tm = XTIMEOUT (obj); |
1060 event_stream_generate_wakeup (unsigned int milliseconds, | 1060 event_stream_generate_wakeup (unsigned int milliseconds, |
1061 unsigned int vanilliseconds, | 1061 unsigned int vanilliseconds, |
1062 Lisp_Object function, Lisp_Object object, | 1062 Lisp_Object function, Lisp_Object object, |
1063 int async_p) | 1063 int async_p) |
1064 { | 1064 { |
1065 #ifdef MC_ALLOC | 1065 #ifdef NEW_GC |
1066 Lisp_Object op = | 1066 Lisp_Object op = |
1067 wrap_pointer_1 (alloc_lrecord_type (Lisp_Timeout, &lrecord_timeout)); | 1067 wrap_pointer_1 (alloc_lrecord_type (Lisp_Timeout, &lrecord_timeout)); |
1068 #else /* not MC_ALLOC */ | 1068 #else /* not NEW_GC */ |
1069 Lisp_Object op = alloc_managed_lcrecord (Vtimeout_free_list); | 1069 Lisp_Object op = alloc_managed_lcrecord (Vtimeout_free_list); |
1070 #endif /* not MC_ALLOC */ | 1070 #endif /* not NEW_GC */ |
1071 Lisp_Timeout *timeout = XTIMEOUT (op); | 1071 Lisp_Timeout *timeout = XTIMEOUT (op); |
1072 EMACS_TIME current_time; | 1072 EMACS_TIME current_time; |
1073 EMACS_TIME interval; | 1073 EMACS_TIME interval; |
1074 | 1074 |
1075 /* Don't just use ++timeout_id_tick, for the (admittedly rare) case | 1075 /* Don't just use ++timeout_id_tick, for the (admittedly rare) case |
1183 is to move frequently-hit timeouts to the front of the | 1183 is to move frequently-hit timeouts to the front of the |
1184 list, which is a good thing. */ | 1184 list, which is a good thing. */ |
1185 *timeout_list = noseeum_cons (op, *timeout_list); | 1185 *timeout_list = noseeum_cons (op, *timeout_list); |
1186 } | 1186 } |
1187 else | 1187 else |
1188 #ifdef MC_ALLOC | 1188 #ifdef NEW_GC |
1189 free_lrecord (op); | 1189 free_lrecord (op); |
1190 #else /* not MC_ALLOC */ | 1190 #else /* not NEW_GC */ |
1191 free_managed_lcrecord (Vtimeout_free_list, op); | 1191 free_managed_lcrecord (Vtimeout_free_list, op); |
1192 #endif /* not MC_ALLOC */ | 1192 #endif /* not NEW_GC */ |
1193 | 1193 |
1194 UNGCPRO; | 1194 UNGCPRO; |
1195 return id; | 1195 return id; |
1196 } | 1196 } |
1197 | 1197 |
1224 delq_no_quit_and_free_cons (op, *timeout_list); | 1224 delq_no_quit_and_free_cons (op, *timeout_list); |
1225 if (async_p) | 1225 if (async_p) |
1226 signal_remove_async_interval_timeout (timeout->interval_id); | 1226 signal_remove_async_interval_timeout (timeout->interval_id); |
1227 else | 1227 else |
1228 event_stream_remove_timeout (timeout->interval_id); | 1228 event_stream_remove_timeout (timeout->interval_id); |
1229 #ifdef MC_ALLOC | 1229 #ifdef NEW_GC |
1230 free_lrecord (op); | 1230 free_lrecord (op); |
1231 #else /* not MC_ALLOC */ | 1231 #else /* not NEW_GC */ |
1232 free_managed_lcrecord (Vtimeout_free_list, op); | 1232 free_managed_lcrecord (Vtimeout_free_list, op); |
1233 #endif /* not MC_ALLOC */ | 1233 #endif /* not NEW_GC */ |
1234 } | 1234 } |
1235 } | 1235 } |
1236 | 1236 |
1237 static int | 1237 static int |
1238 event_stream_wakeup_pending_p (int id, int async_p) | 1238 event_stream_wakeup_pending_p (int id, int async_p) |
4923 reinit_vars_of_event_stream (void) | 4923 reinit_vars_of_event_stream (void) |
4924 { | 4924 { |
4925 recent_keys_ring_index = 0; | 4925 recent_keys_ring_index = 0; |
4926 recent_keys_ring_size = 100; | 4926 recent_keys_ring_size = 100; |
4927 num_input_chars = 0; | 4927 num_input_chars = 0; |
4928 #ifndef MC_ALLOC | 4928 #ifndef NEW_GC |
4929 Vtimeout_free_list = make_lcrecord_list (sizeof (Lisp_Timeout), | 4929 Vtimeout_free_list = make_lcrecord_list (sizeof (Lisp_Timeout), |
4930 &lrecord_timeout); | 4930 &lrecord_timeout); |
4931 staticpro_nodump (&Vtimeout_free_list); | 4931 staticpro_nodump (&Vtimeout_free_list); |
4932 Vcommand_builder_free_list = | 4932 Vcommand_builder_free_list = |
4933 make_lcrecord_list (sizeof (struct command_builder), | 4933 make_lcrecord_list (sizeof (struct command_builder), |
4934 &lrecord_command_builder); | 4934 &lrecord_command_builder); |
4935 staticpro_nodump (&Vcommand_builder_free_list); | 4935 staticpro_nodump (&Vcommand_builder_free_list); |
4936 #endif /* not MC_ALLOC */ | 4936 #endif /* not NEW_GC */ |
4937 the_low_level_timeout_blocktype = | 4937 the_low_level_timeout_blocktype = |
4938 Blocktype_new (struct low_level_timeout_blocktype); | 4938 Blocktype_new (struct low_level_timeout_blocktype); |
4939 something_happened = 0; | 4939 something_happened = 0; |
4940 recursive_sit_for = 0; | 4940 recursive_sit_for = 0; |
4941 in_modal_loop = 0; | 4941 in_modal_loop = 0; |