* async.c (scm_async_click): Set the cdr of a executed handler
authorMarius Vollmer <mvo@zagadka.de>
Sat, 5 Oct 2002 13:06:58 +0000 (13:06 +0000)
committerMarius Vollmer <mvo@zagadka.de>
Sat, 5 Oct 2002 13:06:58 +0000 (13:06 +0000)
cell to SCM_BOOL_F, not SCM_EOL.
(scm_i_queue_async_cell): Queue the cell at the end of the list,
and only if the handler procedure is not already present.
(scm_system_async_mark_for_thread): Initialize cdr of handler cell
with SCM_BOOL_F.
* scmsigs.c (scm_sigaction_for_thread): Likewise.

libguile/async.c
libguile/scmsigs.c

index 53edabd..06fe0b7 100644 (file)
@@ -179,7 +179,7 @@ scm_async_click ()
          do
            {
              SCM c = SCM_CDR (asyncs);
-             SCM_SETCDR (asyncs, SCM_EOL);
+             SCM_SETCDR (asyncs, SCM_BOOL_F);
              scm_call_0 (SCM_CAR (asyncs));
              asyncs = c;
            }
@@ -204,10 +204,23 @@ SCM_DEFINE (scm_system_async, "system-async", 1, 0, 0,
 void
 scm_i_queue_async_cell (SCM c, scm_root_state *root)
 {
-  if (SCM_CDR (c) == SCM_EOL)
+  if (SCM_CDR (c) == SCM_BOOL_F)
     {
-      SCM_SETCDR (c, root->active_asyncs);
-      root->active_asyncs = c;
+      SCM p = root->active_asyncs;
+      SCM_SETCDR (c, SCM_EOL);
+      if (p == SCM_EOL)
+       root->active_asyncs = c;
+      else
+       {
+         SCM pp;
+         while ((pp = SCM_CDR(p)) != SCM_EOL)
+           {
+             if (SCM_CAR (p) == SCM_CAR (c))
+               return;
+             p = pp;
+           }
+         SCM_SETCDR (p, c);
+       }
     }
 }
 
@@ -218,7 +231,7 @@ SCM_DEFINE (scm_system_async_mark_for_thread, "system-async-mark", 1, 1, 0,
            "use the current thread.")
 #define FUNC_NAME s_scm_system_async_mark_for_thread
 {
-  scm_i_queue_async_cell (scm_cons (proc, SCM_EOL),
+  scm_i_queue_async_cell (scm_cons (proc, SCM_BOOL_F),
                          (SCM_UNBNDP (thread)
                           ? scm_root
                           : scm_i_thread_root (thread)));
index c77fad0..ec1926e 100644 (file)
@@ -276,7 +276,7 @@ SCM_DEFINE (scm_sigaction_for_thread, "sigaction", 1, 3, 0,
       handler = close_1 (handler, signum);
       SCM_VECTOR_SET (*signal_handlers, csig, handler);
       SCM_VECTOR_SET (signal_handler_cells, csig,
-                     scm_cons (handler, SCM_EOL));
+                     scm_cons (handler, SCM_BOOL_F));
       SCM_VECTOR_SET (signal_handler_threads, csig, thread);
     }