2 event-queue.c -- New Generation Event Queue
3 Copyright (C) 2006, 2007, 2008 Sebastian Freundt
5 Author: Sebastian Freundt <hroptatyr@sxemacs.org>
7 * This file is part of SXEmacs.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the author nor the names of any contributors
21 * may be used to endorse or promote products derived from this
22 * software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
31 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
32 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
33 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
34 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 /* Inspired by XEmacs' events.c written by Jamie Zawinski */
39 /* Synched up with: Not in FSF. */
43 #include "event-queue.h"
44 #define INCLUDE_EVENTS_H_PRIVATE_SPHERE
49 finalise_event_queue(void *obj, int for_disksave)
51 event_queue_t eq = obj;
53 if (eq == NULL || for_disksave) {
57 SXE_SEMAPH_FINI(&(eq_queue_sem(eq)));
58 free_noseeum_dllist(eq_queue(eq));
63 mark_event_queue(Lisp_Object obj)
65 event_queue_t eq = XEVENT_QUEUE(obj);
69 mark_object((Lisp_Object)dllist_item));
74 make_noseeum_event_queue(void)
76 event_queue_t res = xnew(struct event_queue_s);
78 SXE_SEMAPH_INIT(&(eq_queue_sem(res)));
79 eq_queue(res) = make_noseeum_dllist();
84 static inline event_queue_t
85 allocate_event_queue(void)
88 alloc_lcrecord_type(struct event_queue_s, &lrecord_event_queue);
93 make_event_queue(void)
95 event_queue_t res = allocate_event_queue();
97 SXE_SEMAPH_INIT(&(eq_queue_sem(res)));
98 eq_queue(res) = make_noseeum_dllist();
104 free_event_queue(event_queue_t eq)
106 finalise_event_queue(eq, 0);
111 DEFINE_LRECORD_IMPLEMENTATION("event-queue", event_queue,
112 mark_event_queue, NULL,
113 finalise_event_queue,
114 NULL, NULL, 0, struct event_queue_s);
118 finalise_event_prique(void *obj, int for_disksave)
120 event_prique_t ep = obj;
124 SXE_SEMAPH_FINI(&(eq_prique_sem(ep)));
125 free_noseeum_dllist(eq_prique(ep));
130 mark_event_prique(Lisp_Object obj)
136 make_event_prique(void)
138 event_prique_t res = xnew(struct event_prique_s);
140 SXE_SEMAPH_INIT(&(eq_prique_sem(res)));
141 eq_prique(res) = NULL;
147 free_event_prique(event_prique_t eq)
149 finalise_event_prique(eq, 0);
154 DEFINE_LRECORD_IMPLEMENTATION("event-prique", event_prique,
155 mark_event_prique, NULL,
156 finalise_event_prique,
157 NULL, NULL, 0, struct event_prique_s);
159 /* stuff with private data aboard */
161 eq_enqueue_event_chain(event_queue_t eq, Lisp_Object ec)
165 ec = XEVENT_NEXT(ec);
172 /************************************************************************/
174 /************************************************************************/
176 void syms_of_event_queue(void)
178 INIT_LRECORD_IMPLEMENTATION(event_queue);
179 INIT_LRECORD_IMPLEMENTATION(event_prique);
182 /* event-queue.c ends here */