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;
55 SXE_SEMAPH_FINI(&(eq_queue_sem(eq)));
56 free_noseeum_dllist(eq_queue(eq));
61 mark_event_queue(Lisp_Object obj)
63 event_queue_t eq = XEVENT_QUEUE(obj);
67 mark_object((Lisp_Object)dllist_item));
72 make_noseeum_event_queue(void)
74 event_queue_t res = xnew(struct event_queue_s);
76 SXE_SEMAPH_INIT(&(eq_queue_sem(res)));
77 eq_queue(res) = make_noseeum_dllist();
82 static inline event_queue_t
83 allocate_event_queue(void)
86 alloc_lcrecord_type(struct event_queue_s, &lrecord_event_queue);
91 make_event_queue(void)
93 event_queue_t res = allocate_event_queue();
95 SXE_SEMAPH_INIT(&(eq_queue_sem(res)));
96 eq_queue(res) = make_noseeum_dllist();
102 free_event_queue(event_queue_t eq)
104 finalise_event_queue(eq, 0);
109 DEFINE_LRECORD_IMPLEMENTATION("event-queue", event_queue,
110 mark_event_queue, NULL,
111 finalise_event_queue,
112 NULL, NULL, 0, struct event_queue_s);
116 finalise_event_prique(void *obj, int for_disksave)
118 event_prique_t ep = obj;
122 SXE_SEMAPH_FINI(&(eq_prique_sem(ep)));
123 free_noseeum_dllist(eq_prique(ep));
128 mark_event_prique(Lisp_Object obj)
134 make_event_prique(void)
136 event_prique_t res = xnew(struct event_prique_s);
138 SXE_SEMAPH_INIT(&(eq_prique_sem(res)));
139 eq_prique(res) = NULL;
145 free_event_prique(event_prique_t eq)
147 finalise_event_prique(eq, 0);
152 DEFINE_LRECORD_IMPLEMENTATION("event-prique", event_prique,
153 mark_event_prique, NULL,
154 finalise_event_prique,
155 NULL, NULL, 0, struct event_prique_s);
157 /* stuff with private data aboard */
159 eq_enqueue_event_chain(event_queue_t eq, Lisp_Object ec)
163 ec = XEVENT_NEXT(ec);
170 /************************************************************************/
172 /************************************************************************/
174 void syms_of_event_queue(void)
176 INIT_LRECORD_IMPLEMENTATION(event_queue);
177 INIT_LRECORD_IMPLEMENTATION(event_prique);
180 /* event-queue.c ends here */