[plt-dev] thread-specifics [PATCH]

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Tue Mar 3 14:31:33 EST 2009

The attached patch adds two new atomic primitives implementing 
thread-specifics:
(thread-get-specific thread? (undefined (lambda () #f)) -> any?
  Retrieve the specific value from a thread.
  The optional undefined thunk is used to provide a value when the
  specific has not been set by the target thread.
(thread-set-specific! any?) -> void
  Set the specific value for the current thread.

These primitives are useful for communicating publicly visible information
and simplify common synchronization patterns.

Some simple examples in the test module [thread-specific.ss]:
async: an asynchronous computation wrapper around threads.
tagged: a state machine that tags its current state.
my-thread: a synchronous thread spawner that places an ownership mark.

test run:
> (require "test-threadsp.ss")
> (run-tests)

(sync (async a1))
  => 1
  ; correct

(exn? v2)
  => #t
  ; correct

(thread-get-specific tag)
  => b1
  ; correct

(thread-get-specific tag)
  => b2
  ; correct

(thread-get-specific tag)
  => b3
  ; correct

(my-thread? (thread void) mark)
  => #f
  ; correct

(my-thread? (my-thread void mark) mark)
  => #t
  ; correct

-- vyzo
-------------- next part --------------
Index: mzscheme/include/scheme.h
===================================================================
--- mzscheme/include/scheme.h	(revision 13918)
+++ mzscheme/include/scheme.h	(working copy)
@@ -1090,6 +1090,8 @@
   Scheme_Object *mbox_last;
   Scheme_Object *mbox_sema;
 
+  Scheme_Object *specific;
+
 #ifdef MZ_PRECISE_GC
   struct GC_Thread_Info *gc_info; /* managed by the GC */
 #endif
Index: mzscheme/src/mzmark.c
===================================================================
--- mzscheme/src/mzmark.c	(revision 13918)
+++ mzscheme/src/mzmark.c	(working copy)
@@ -1693,6 +1693,8 @@
   gcMARK(pr->mbox_first);
   gcMARK(pr->mbox_last);
   gcMARK(pr->mbox_sema);
+
+  gcMARK(pr->specific);
   return
   gcBYTES_TO_WORDS(sizeof(Scheme_Thread));
 }
@@ -1803,6 +1805,8 @@
   gcFIXUP(pr->mbox_first);
   gcFIXUP(pr->mbox_last);
   gcFIXUP(pr->mbox_sema);
+
+  gcFIXUP(pr->specific);
   return
   gcBYTES_TO_WORDS(sizeof(Scheme_Thread));
 }
Index: mzscheme/src/thread.c
===================================================================
--- mzscheme/src/thread.c	(revision 13918)
+++ mzscheme/src/thread.c	(working copy)
@@ -2325,6 +2325,8 @@
   process->mbox_last = NULL;
   process->mbox_sema = NULL;
 
+  process->specific = NULL;
+
   process->mref = NULL;
   process->extra_mrefs = NULL;
 
Index: mzscheme/src/mzmarksrc.c
===================================================================
--- mzscheme/src/mzmarksrc.c	(revision 13918)
+++ mzscheme/src/mzmarksrc.c	(working copy)
@@ -706,6 +706,8 @@
   gcMARK(pr->mbox_first);
   gcMARK(pr->mbox_last);
   gcMARK(pr->mbox_sema);
+
+  gcMARK(pr->specific);
  size:
   gcBYTES_TO_WORDS(sizeof(Scheme_Thread));
 }
Index: mzscheme/src/sema.c
===================================================================
--- mzscheme/src/sema.c	(revision 13918)
+++ mzscheme/src/sema.c	(working copy)
@@ -44,6 +44,9 @@
 static Scheme_Object *thread_receive_evt(int n, Scheme_Object **p);
 static Scheme_Object *thread_rewind_receive(int n, Scheme_Object **p);
 
+static Scheme_Object *thread_get_specific(int n, Scheme_Object **p);
+static Scheme_Object *thread_set_specific(int n, Scheme_Object **p);
+
 static Scheme_Object *make_alarm(int n, Scheme_Object **p);
 static Scheme_Object *make_sys_idle(int n, Scheme_Object **p);
 
@@ -170,6 +173,17 @@
 						      1, 1), 
 			     env);
 
+  scheme_add_global_constant("thread-get-specific", 
+                 scheme_make_prim_w_arity(thread_get_specific,
+						      "thread-get-specific", 
+						      1, 2), 
+			     env);
+  scheme_add_global_constant("thread-set-specific!", 
+                 scheme_make_prim_w_arity(thread_set_specific,
+						      "thread-set-specific!", 
+						      1, 1), 
+			     env);
+
   scheme_add_global_constant("alarm-evt", 
 			     scheme_make_prim_w_arity(make_alarm,
 						      "alarm-evt",
@@ -1207,6 +1221,33 @@
 }
 
 /**********************************************************************/
+/*                      Thread specifics                              */
+/**********************************************************************/
+static Scheme_Object *thread_get_specific(int argc, Scheme_Object **argv)
+{
+  if (SCHEME_THREADP(argv[0])) {
+    Scheme_Thread *p = (Scheme_Thread*)argv[0];
+    if (argc > 1)
+      scheme_check_proc_arity2("thread-get-specific", 0, 1, argc, argv, 1);
+    
+    if (p->specific)
+      return p->specific;
+    else if (argc > 1) 
+      return _scheme_tail_apply(argv[1], 0, NULL);
+    else return scheme_false;
+  } else 
+    scheme_wrong_type("thread-get-specific", "thread", 0, argc, argv);
+
+  return NULL;
+}
+
+static Scheme_Object *thread_set_specific(int argc, Scheme_Object **argv) 
+{
+  scheme_current_thread->specific = argv[0];
+  return scheme_void;
+}
+
+/**********************************************************************/
 /*                             alarms                                 */
 /**********************************************************************/
 
Index: mzscheme/src/schminc.h
===================================================================
--- mzscheme/src/schminc.h	(revision 13918)
+++ mzscheme/src/schminc.h	(working copy)
@@ -11,9 +11,9 @@
    EXPECTED_PRIM_COUNT to the new value, and then USE_COMPILED_STARTUP
    can be set to 1 again. */
 
-#define USE_COMPILED_STARTUP 1
+#define USE_COMPILED_STARTUP 0
 
-#define EXPECTED_PRIM_COUNT 947
+#define EXPECTED_PRIM_COUNT 949
 
 #ifdef MZSCHEME_SOMETHING_OMITTED
 # undef USE_COMPILED_STARTUP
Index: mzscheme/src/cstartup.inc
===================================================================
--- mzscheme/src/cstartup.inc	(revision 13918)
+++ mzscheme/src/cstartup.inc	(working copy)
@@ -1,560 +0,0 @@
-  {
-    static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,49,46,52,46,50,50,0,0,0,1,0,0,3,0,12,0,
-17,0,20,0,27,0,40,0,47,0,51,0,58,0,63,0,68,0,72,0,78,
-0,92,0,106,0,109,0,115,0,119,0,121,0,132,0,134,0,148,0,155,0,
-177,0,179,0,193,0,253,0,23,1,32,1,41,1,51,1,87,1,126,1,165,
-1,234,1,42,2,130,2,194,2,199,2,219,2,110,3,130,3,181,3,247,3,
-132,4,34,5,84,5,107,5,186,5,0,0,132,7,0,0,29,11,11,68,104,
-101,114,101,45,115,116,120,64,99,111,110,100,62,111,114,66,108,101,116,114,101,
-99,72,112,97,114,97,109,101,116,101,114,105,122,101,66,117,110,108,101,115,115,
-63,108,101,116,66,100,101,102,105,110,101,64,119,104,101,110,64,108,101,116,42,
-63,97,110,100,65,113,117,111,116,101,29,94,2,13,68,35,37,107,101,114,110,
-101,108,11,29,94,2,13,68,35,37,112,97,114,97,109,122,11,62,105,102,65,
-98,101,103,105,110,63,115,116,120,61,115,70,108,101,116,45,118,97,108,117,101,
-115,61,120,73,108,101,116,114,101,99,45,118,97,108,117,101,115,66,108,97,109,
-98,100,97,1,20,112,97,114,97,109,101,116,101,114,105,122,97,116,105,111,110,
-45,107,101,121,61,118,73,100,101,102,105,110,101,45,118,97,108,117,101,115,98,
-10,35,11,8,134,228,94,159,2,15,35,35,159,2,14,35,35,16,20,2,3,
-2,1,2,5,2,1,2,6,2,1,2,7,2,1,2,8,2,1,2,9,2,
-1,2,10,2,1,2,4,2,1,2,11,2,1,2,12,2,1,97,36,11,8,
-134,228,93,159,2,14,35,36,16,2,2,2,161,2,1,36,2,2,2,1,2,
-2,97,10,11,11,8,134,228,16,0,97,10,37,11,8,134,228,16,0,13,16,
-4,35,29,11,11,2,1,11,18,16,2,99,64,104,101,114,101,8,31,8,30,
-8,29,8,28,8,27,93,8,224,13,57,0,0,95,9,8,224,13,57,0,0,
-2,1,27,248,22,135,4,23,196,1,249,22,128,4,80,158,38,35,251,22,75,
-2,16,248,22,90,23,200,2,12,249,22,65,2,17,248,22,92,23,202,1,27,
-248,22,135,4,23,196,1,249,22,128,4,80,158,38,35,251,22,75,2,16,248,
-22,90,23,200,2,249,22,65,2,17,248,22,92,23,202,1,12,27,248,22,67,
-248,22,135,4,23,197,1,28,248,22,73,23,194,2,20,15,159,36,35,36,28,
-248,22,73,248,22,67,23,195,2,248,22,66,193,249,22,128,4,80,158,38,35,
-251,22,75,2,16,248,22,66,23,200,2,249,22,65,2,12,248,22,67,23,202,
-1,11,18,16,2,101,10,8,31,8,30,8,29,8,28,8,27,16,4,11,11,
-2,18,3,1,7,101,110,118,57,55,57,53,16,4,11,11,2,19,3,1,7,
-101,110,118,57,55,57,54,93,8,224,14,57,0,0,95,9,8,224,14,57,0,
-0,2,1,27,248,22,67,248,22,135,4,23,197,1,28,248,22,73,23,194,2,
-20,15,159,36,35,36,28,248,22,73,248,22,67,23,195,2,248,22,66,193,249,
-22,128,4,80,158,38,35,250,22,75,2,20,248,22,75,249,22,75,248,22,75,
-2,21,248,22,66,23,202,2,251,22,75,2,16,2,21,2,21,249,22,65,2,
-4,248,22,67,23,205,1,18,16,2,101,11,8,31,8,30,8,29,8,28,8,
-27,16,4,11,11,2,18,3,1,7,101,110,118,57,55,57,56,16,4,11,11,
-2,19,3,1,7,101,110,118,57,55,57,57,93,8,224,15,57,0,0,95,9,
-8,224,15,57,0,0,2,1,248,22,135,4,193,27,248,22,135,4,194,249,22,
-65,248,22,75,248,22,66,196,248,22,67,195,27,248,22,67,248,22,135,4,23,
-197,1,249,22,128,4,80,158,38,35,28,248,22,53,248,22,129,4,248,22,66,
-23,198,2,27,249,22,2,32,0,89,162,8,44,36,42,9,222,33,39,248,22,
-135,4,248,22,90,23,200,2,250,22,75,2,22,248,22,75,249,22,75,248,22,
-75,248,22,66,23,204,2,250,22,76,2,23,249,22,2,22,66,23,204,2,248,
-22,92,23,206,2,249,22,65,248,22,66,23,202,1,249,22,2,22,90,23,200,
-1,250,22,76,2,20,249,22,2,32,0,89,162,8,44,36,46,9,222,33,40,
-248,22,135,4,248,22,66,201,248,22,67,198,27,248,22,135,4,194,249,22,65,
-248,22,75,248,22,66,196,248,22,67,195,27,248,22,67,248,22,135,4,23,197,
-1,249,22,128,4,80,158,38,35,250,22,76,2,22,249,22,2,32,0,89,162,
-8,44,36,46,9,222,33,42,248,22,135,4,248,22,66,201,248,22,67,198,27,
-248,22,67,248,22,135,4,196,27,248,22,135,4,248,22,66,195,249,22,128,4,
-80,158,39,35,28,248,22,73,195,250,22,76,2,20,9,248,22,67,199,250,22,
-75,2,8,248,22,75,248,22,66,199,250,22,76,2,11,248,22,67,201,248,22,
-67,202,27,248,22,67,248,22,135,4,23,197,1,27,249,22,1,22,79,249,22,
-2,22,135,4,248,22,135,4,248,22,66,199,249,22,128,4,80,158,39,35,251,
-22,75,1,22,119,105,116,104,45,99,111,110,116,105,110,117,97,116,105,111,110,
-45,109,97,114,107,2,24,250,22,76,1,23,101,120,116,101,110,100,45,112,97,
-114,97,109,101,116,101,114,105,122,97,116,105,111,110,21,95,1,27,99,111,110,
-116,105,110,117,97,116,105,111,110,45,109,97,114,107,45,115,101,116,45,102,105,
-114,115,116,11,2,24,201,250,22,76,2,20,9,248,22,67,203,27,248,22,67,
-248,22,135,4,23,197,1,28,248,22,73,23,194,2,20,15,159,36,35,36,249,
-22,128,4,80,158,38,35,27,248,22,135,4,248,22,66,23,198,2,28,249,22,
-164,8,62,61,62,248,22,129,4,248,22,90,23,197,2,250,22,75,2,20,248,
-22,75,249,22,75,21,93,2,25,248,22,66,199,250,22,76,2,3,249,22,75,
-2,25,249,22,75,248,22,99,203,2,25,248,22,67,202,251,22,75,2,16,28,
-249,22,164,8,248,22,129,4,248,22,66,23,201,2,64,101,108,115,101,10,248,
-22,66,23,198,2,250,22,76,2,20,9,248,22,67,23,201,1,249,22,65,2,
-3,248,22,67,23,203,1,100,8,31,8,30,8,29,8,28,8,27,16,4,11,
-11,2,18,3,1,7,101,110,118,57,56,50,49,16,4,11,11,2,19,3,1,
-7,101,110,118,57,56,50,50,93,8,224,16,57,0,0,18,16,2,158,94,10,
-64,118,111,105,100,8,47,95,9,8,224,16,57,0,0,2,1,27,248,22,67,
-248,22,135,4,196,249,22,128,4,80,158,38,35,28,248,22,53,248,22,129,4,
-248,22,66,197,250,22,75,2,26,248,22,75,248,22,66,199,248,22,90,198,27,
-248,22,129,4,248,22,66,197,250,22,75,2,26,248,22,75,248,22,66,197,250,
-22,76,2,23,248,22,67,199,248,22,67,202,159,35,20,103,159,35,16,1,11,
-16,0,83,158,41,20,100,143,69,35,37,109,105,110,45,115,116,120,2,1,11,
-10,11,10,35,80,158,35,35,20,103,159,35,16,0,16,0,11,11,16,1,2,
-2,36,16,0,35,16,0,35,11,11,38,35,11,11,16,10,2,3,2,4,2,
-5,2,6,2,7,2,8,2,9,2,10,2,11,2,12,16,10,11,11,11,11,
-11,11,11,11,11,11,16,10,2,3,2,4,2,5,2,6,2,7,2,8,2,
-9,2,10,2,11,2,12,35,45,36,11,11,16,0,16,0,16,0,35,35,11,
-11,11,16,0,16,0,16,0,35,35,16,11,16,5,2,2,20,15,159,35,35,
-35,35,20,103,159,35,16,0,16,1,33,32,10,16,5,2,7,89,162,8,44,
-36,52,9,223,0,33,33,35,20,103,159,35,16,1,2,2,16,0,11,16,5,
-2,10,89,162,8,44,36,52,9,223,0,33,34,35,20,103,159,35,16,1,2,
-2,16,0,11,16,5,2,12,89,162,8,44,36,52,9,223,0,33,35,35,20,
-103,159,35,16,1,2,2,16,1,33,36,11,16,5,2,4,89,162,8,44,36,
-55,9,223,0,33,37,35,20,103,159,35,16,1,2,2,16,1,33,38,11,16,
-5,2,8,89,162,8,44,36,57,9,223,0,33,41,35,20,103,159,35,16,1,
-2,2,16,0,11,16,5,2,5,89,162,8,44,36,52,9,223,0,33,43,35,
-20,103,159,35,16,1,2,2,16,0,11,16,5,2,11,89,162,8,44,36,53,
-9,223,0,33,44,35,20,103,159,35,16,1,2,2,16,0,11,16,5,2,6,
-89,162,8,44,36,54,9,223,0,33,45,35,20,103,159,35,16,1,2,2,16,
-0,11,16,5,2,3,89,162,8,44,36,57,9,223,0,33,46,35,20,103,159,
-35,16,1,2,2,16,1,33,48,11,16,5,2,9,89,162,8,44,36,53,9,
-223,0,33,49,35,20,103,159,35,16,1,2,2,16,0,11,16,0,94,2,14,
-2,15,93,2,14,9,9,35,0};
-    EVAL_ONE_SIZED_STR((char *)expr, 2045);
-  }
-  {
-    static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,49,46,52,46,50,59,0,0,0,1,0,0,13,0,18,0,
-35,0,50,0,68,0,84,0,94,0,112,0,132,0,148,0,166,0,197,0,226,
-0,248,0,6,1,12,1,26,1,31,1,41,1,49,1,77,1,109,1,154,1,
-199,1,223,1,6,2,8,2,65,2,155,3,196,3,31,5,135,5,239,5,100,
-6,114,6,148,6,164,6,14,8,28,8,191,8,192,9,192,10,199,10,206,10,
-213,10,88,11,101,11,56,12,158,12,171,12,193,12,145,13,49,14,121,15,129,
-15,137,15,163,15,18,16,0,0,6,19,0,0,72,112,97,116,104,45,115,116,
-114,105,110,103,63,64,98,115,98,115,76,110,111,114,109,97,108,45,99,97,115,
-101,45,112,97,116,104,74,45,99,104,101,99,107,45,114,101,108,112,97,116,104,
-77,45,99,104,101,99,107,45,99,111,108,108,101,99,116,105,111,110,75,99,111,
-108,108,101,99,116,105,111,110,45,112,97,116,104,69,45,102,105,110,100,45,99,
-111,108,77,99,104,101,99,107,45,115,117,102,102,105,120,45,99,97,108,108,79,
-112,97,116,104,45,114,101,112,108,97,99,101,45,115,117,102,102,105,120,75,112,
-97,116,104,45,97,100,100,45,115,117,102,102,105,120,77,108,111,97,100,47,117,
-115,101,45,99,111,109,112,105,108,101,100,1,29,102,105,110,100,45,108,105,98,
-114,97,114,121,45,99,111,108,108,101,99,116,105,111,110,45,112,97,116,104,115,
-1,27,112,97,116,104,45,108,105,115,116,45,115,116,114,105,110,103,45,62,112,
-97,116,104,45,108,105,115,116,1,20,102,105,110,100,45,101,120,101,99,117,116,
-97,98,108,101,45,112,97,116,104,73,101,109,98,101,100,100,101,100,45,108,111,
-97,100,65,113,117,111,116,101,29,94,2,16,68,35,37,112,97,114,97,109,122,
-11,64,108,111,111,112,69,101,120,101,99,45,102,105,108,101,67,119,105,110,100,
-111,119,115,6,25,25,112,97,116,104,32,111,114,32,118,97,108,105,100,45,112,
-97,116,104,32,115,116,114,105,110,103,6,29,29,126,97,58,32,105,110,118,97,
-108,105,100,32,114,101,108,97,116,105,118,101,32,112,97,116,104,58,32,126,115,
-6,42,42,126,97,58,32,99,111,108,108,101,99,116,105,111,110,32,110,111,116,
-32,102,111,117,110,100,58,32,126,115,32,105,110,32,97,110,121,32,111,102,58,
-32,126,115,6,42,42,112,97,116,104,32,40,102,111,114,32,97,110,121,32,115,
-121,115,116,101,109,41,32,111,114,32,118,97,108,105,100,45,112,97,116,104,32,
-115,116,114,105,110,103,6,21,21,115,116,114,105,110,103,32,111,114,32,98,121,
-116,101,32,115,116,114,105,110,103,6,36,36,99,97,110,110,111,116,32,97,100,
-100,32,97,32,115,117,102,102,105,120,32,116,111,32,97,32,114,111,111,116,32,
-112,97,116,104,58,32,5,0,27,20,14,159,80,158,36,50,250,80,158,39,51,
-249,22,27,11,80,158,41,50,22,182,12,10,248,22,157,5,23,196,2,28,248,
-22,154,6,23,194,2,12,87,94,248,22,168,8,23,194,1,248,80,159,37,53,
-36,195,28,248,22,73,23,195,2,9,27,248,22,66,23,196,2,27,28,248,22,
-163,13,23,195,2,23,194,1,28,248,22,162,13,23,195,2,249,22,164,13,23,
-196,1,250,80,158,42,48,248,22,178,13,2,19,11,10,250,80,158,40,48,248,
-22,178,13,2,19,23,197,1,10,28,23,193,2,249,22,65,248,22,166,13,249,
-22,164,13,23,198,1,247,22,179,13,27,248,22,67,23,200,1,28,248,22,73,
-23,194,2,9,27,248,22,66,23,195,2,27,28,248,22,163,13,23,195,2,23,
-194,1,28,248,22,162,13,23,195,2,249,22,164,13,23,196,1,250,80,158,47,
-48,248,22,178,13,2,19,11,10,250,80,158,45,48,248,22,178,13,2,19,23,
-197,1,10,28,23,193,2,249,22,65,248,22,166,13,249,22,164,13,23,198,1,
-247,22,179,13,248,80,159,45,52,36,248,22,67,23,199,1,87,94,23,193,1,
-248,80,159,43,52,36,248,22,67,23,197,1,87,94,23,193,1,27,248,22,67,
-23,198,1,28,248,22,73,23,194,2,9,27,248,22,66,23,195,2,27,28,248,
-22,163,13,23,195,2,23,194,1,28,248,22,162,13,23,195,2,249,22,164,13,
-23,196,1,250,80,158,45,48,248,22,178,13,2,19,11,10,250,80,158,43,48,
-248,22,178,13,2,19,23,197,1,10,28,23,193,2,249,22,65,248,22,166,13,
-249,22,164,13,23,198,1,247,22,179,13,248,80,159,43,52,36,248,22,67,23,
-199,1,248,80,159,41,52,36,248,22,67,196,27,248,22,139,13,23,195,2,28,
-23,193,2,192,87,94,23,193,1,28,248,22,159,6,23,195,2,27,248,22,161,
-13,195,28,192,192,248,22,162,13,195,11,87,94,28,28,248,22,140,13,23,195,
-2,10,27,248,22,139,13,23,196,2,28,23,193,2,192,87,94,23,193,1,28,
-248,22,159,6,23,196,2,27,248,22,161,13,23,197,2,28,23,193,2,192,87,
-94,23,193,1,248,22,162,13,23,197,2,11,12,250,22,132,9,76,110,111,114,
-109,97,108,45,112,97,116,104,45,99,97,115,101,6,42,42,112,97,116,104,32,
-40,102,111,114,32,97,110,121,32,115,121,115,116,101,109,41,32,111,114,32,118,
-97,108,105,100,45,112,97,116,104,32,115,116,114,105,110,103,23,197,2,28,28,
-248,22,140,13,23,195,2,249,22,164,8,248,22,141,13,23,197,2,2,20,249,
-22,164,8,247,22,178,7,2,20,27,28,248,22,159,6,23,196,2,23,195,2,
-248,22,168,7,248,22,144,13,23,197,2,28,249,22,191,13,0,21,35,114,120,
-34,94,91,92,92,93,91,92,92,93,91,63,93,91,92,92,93,34,23,195,2,
-28,248,22,159,6,195,248,22,147,13,195,194,27,248,22,134,7,23,195,1,249,
-22,148,13,248,22,171,7,250,22,133,14,0,6,35,114,120,34,47,34,28,249,
-22,191,13,0,22,35,114,120,34,91,47,92,92,93,91,46,32,93,43,91,47,
-92,92,93,42,36,34,23,201,2,23,199,1,250,22,133,14,0,19,35,114,120,
-34,91,32,46,93,43,40,91,47,92,92,93,42,41,36,34,23,202,1,6,2,
-2,92,49,80,159,43,36,37,2,20,28,248,22,159,6,194,248,22,147,13,194,
-193,87,94,28,27,248,22,139,13,23,196,2,28,23,193,2,192,87,94,23,193,
-1,28,248,22,159,6,23,196,2,27,248,22,161,13,23,197,2,28,23,193,2,
-192,87,94,23,193,1,248,22,162,13,23,197,2,11,12,250,22,132,9,23,196,
-2,2,21,23,197,2,28,248,22,161,13,23,195,2,12,248,22,158,11,249,22,
-167,10,248,22,188,6,250,22,143,7,2,22,23,200,1,23,201,1,247,22,23,
-87,94,28,27,248,22,139,13,23,196,2,28,23,193,2,192,87,94,23,193,1,
-28,248,22,159,6,23,196,2,27,248,22,161,13,23,197,2,28,23,193,2,192,
-87,94,23,193,1,248,22,162,13,23,197,2,11,12,250,22,132,9,23,196,2,
-2,21,23,197,2,28,248,22,161,13,23,195,2,12,248,22,158,11,249,22,167,
-10,248,22,188,6,250,22,143,7,2,22,23,200,1,23,201,1,247,22,23,87,
-94,87,94,28,27,248,22,139,13,23,196,2,28,23,193,2,192,87,94,23,193,
-1,28,248,22,159,6,23,196,2,27,248,22,161,13,23,197,2,28,23,193,2,
-192,87,94,23,193,1,248,22,162,13,23,197,2,11,12,250,22,132,9,195,2,
-21,23,197,2,28,248,22,161,13,23,195,2,12,248,22,158,11,249,22,167,10,
-248,22,188,6,250,22,143,7,2,22,199,23,201,1,247,22,23,249,22,3,89,
-162,8,44,36,49,9,223,2,33,33,196,248,22,158,11,249,22,133,11,23,196,
-1,247,22,23,87,94,250,80,159,38,39,36,2,6,196,197,251,80,159,39,41,
-36,2,6,32,0,89,162,8,44,36,44,9,222,33,35,197,198,32,37,89,162,
-43,41,58,65,99,108,111,111,112,222,33,38,28,248,22,73,23,199,2,87,94,
-23,198,1,248,23,196,1,251,22,143,7,2,23,23,199,1,28,248,22,73,23,
-203,2,87,94,23,202,1,23,201,1,250,22,1,22,157,13,23,204,1,23,205,
-1,23,198,1,27,249,22,157,13,248,22,66,23,202,2,23,199,2,28,248,22,
-152,13,23,194,2,27,250,22,1,22,157,13,23,197,1,23,202,2,28,248,22,
-152,13,23,194,2,192,87,94,23,193,1,27,248,22,67,23,202,1,28,248,22,
-73,23,194,2,87,94,23,193,1,248,23,199,1,251,22,143,7,2,23,23,202,
-1,28,248,22,73,23,206,2,87,94,23,205,1,23,204,1,250,22,1,22,157,
-13,23,207,1,23,208,1,23,201,1,27,249,22,157,13,248,22,66,23,197,2,
-23,202,2,28,248,22,152,13,23,194,2,27,250,22,1,22,157,13,23,197,1,
-204,28,248,22,152,13,193,192,253,2,37,203,204,205,206,23,15,248,22,67,201,
-253,2,37,202,203,204,205,206,248,22,67,200,87,94,23,193,1,27,248,22,67,
-23,201,1,28,248,22,73,23,194,2,87,94,23,193,1,248,23,198,1,251,22,
-143,7,2,23,23,201,1,28,248,22,73,23,205,2,87,94,23,204,1,23,203,
-1,250,22,1,22,157,13,23,206,1,23,207,1,23,200,1,27,249,22,157,13,
-248,22,66,23,197,2,23,201,2,28,248,22,152,13,23,194,2,27,250,22,1,
-22,157,13,23,197,1,203,28,248,22,152,13,193,192,253,2,37,202,203,204,205,
-206,248,22,67,201,253,2,37,201,202,203,204,205,248,22,67,200,27,247,22,180,
-13,253,2,37,198,199,200,201,202,198,87,95,28,28,248,22,140,13,23,194,2,
-10,27,248,22,139,13,23,195,2,28,23,193,2,192,87,94,23,193,1,28,248,
-22,159,6,23,195,2,27,248,22,161,13,23,196,2,28,23,193,2,192,87,94,
-23,193,1,248,22,162,13,23,196,2,11,12,252,22,132,9,23,200,2,2,24,
-35,23,198,2,23,199,2,28,28,248,22,159,6,23,195,2,10,248,22,147,7,
-23,195,2,87,94,23,194,1,12,252,22,132,9,23,200,2,2,25,36,23,198,
-2,23,199,1,91,159,38,11,90,161,38,35,11,248,22,160,13,23,197,2,87,
-94,23,195,1,87,94,28,192,12,250,22,133,9,23,201,1,2,26,23,199,1,
-249,22,7,194,195,91,159,37,11,90,161,37,35,11,87,95,28,28,248,22,140,
-13,23,196,2,10,27,248,22,139,13,23,197,2,28,23,193,2,192,87,94,23,
-193,1,28,248,22,159,6,23,197,2,27,248,22,161,13,23,198,2,28,23,193,
-2,192,87,94,23,193,1,248,22,162,13,23,198,2,11,12,252,22,132,9,2,
-9,2,24,35,23,200,2,23,201,2,28,28,248,22,159,6,23,197,2,10,248,
-22,147,7,23,197,2,12,252,22,132,9,2,9,2,25,36,23,200,2,23,201,
-2,91,159,38,11,90,161,38,35,11,248,22,160,13,23,199,2,87,94,23,195,
-1,87,94,28,192,12,250,22,133,9,2,9,2,26,23,201,2,249,22,7,194,
-195,27,249,22,149,13,250,22,132,14,0,18,35,114,120,35,34,40,91,46,93,
-91,94,46,93,42,124,41,36,34,248,22,145,13,23,201,1,28,248,22,159,6,
-23,203,2,249,22,171,7,23,204,1,8,63,23,202,1,28,248,22,140,13,23,
-199,2,248,22,141,13,23,199,1,87,94,23,198,1,247,22,142,13,28,248,22,
-139,13,194,249,22,157,13,195,194,192,91,159,37,11,90,161,37,35,11,87,95,
-28,28,248,22,140,13,23,196,2,10,27,248,22,139,13,23,197,2,28,23,193,
-2,192,87,94,23,193,1,28,248,22,159,6,23,197,2,27,248,22,161,13,23,
-198,2,28,23,193,2,192,87,94,23,193,1,248,22,162,13,23,198,2,11,12,
-252,22,132,9,2,10,2,24,35,23,200,2,23,201,2,28,28,248,22,159,6,
-23,197,2,10,248,22,147,7,23,197,2,12,252,22,132,9,2,10,2,25,36,
-23,200,2,23,201,2,91,159,38,11,90,161,38,35,11,248,22,160,13,23,199,
-2,87,94,23,195,1,87,94,28,192,12,250,22,133,9,2,10,2,26,23,201,
-2,249,22,7,194,195,27,249,22,149,13,249,22,157,7,250,22,133,14,0,9,
-35,114,120,35,34,91,46,93,34,248,22,145,13,23,203,1,6,1,1,95,28,
-248,22,159,6,23,202,2,249,22,171,7,23,203,1,8,63,23,201,1,28,248,
-22,140,13,23,199,2,248,22,141,13,23,199,1,87,94,23,198,1,247,22,142,
-13,28,248,22,139,13,194,249,22,157,13,195,194,192,249,247,22,190,4,194,11,
-249,80,158,37,46,9,9,249,80,158,37,46,195,9,27,247,22,182,13,249,80,
-158,38,47,28,23,195,2,27,248,22,176,7,6,11,11,80,76,84,67,79,76,
-76,69,67,84,83,28,192,192,6,0,0,6,0,0,27,28,23,196,1,250,22,
-157,13,248,22,178,13,69,97,100,100,111,110,45,100,105,114,247,22,174,7,6,
-8,8,99,111,108,108,101,99,116,115,11,27,248,80,159,41,52,36,250,22,79,
-23,203,1,248,22,75,248,22,178,13,72,99,111,108,108,101,99,116,115,45,100,
-105,114,23,204,1,28,23,194,2,249,22,65,23,196,1,23,195,1,192,32,47,
-89,162,8,44,38,54,2,18,222,33,48,27,249,22,189,13,23,197,2,23,198,
-2,28,23,193,2,87,94,23,196,1,27,248,22,90,23,195,2,27,27,248,22,
-99,23,197,1,27,249,22,189,13,23,201,2,23,196,2,28,23,193,2,87,94,
-23,194,1,27,248,22,90,23,195,2,27,250,2,47,23,203,2,23,204,1,248,
-22,99,23,199,1,28,249,22,153,7,23,196,2,2,27,249,22,79,23,202,2,
-194,249,22,65,248,22,148,13,23,197,1,23,195,1,87,95,23,199,1,23,193,
-1,28,249,22,153,7,23,196,2,2,27,249,22,79,23,200,2,9,249,22,65,
-248,22,148,13,23,197,1,9,28,249,22,153,7,23,196,2,2,27,249,22,79,
-197,194,87,94,23,196,1,249,22,65,248,22,148,13,23,197,1,194,87,94,23,
-193,1,28,249,22,153,7,23,198,2,2,27,249,22,79,195,9,87,94,23,194,
-1,249,22,65,248,22,148,13,23,199,1,9,87,95,28,28,248,22,147,7,194,
-10,248,22,159,6,194,12,250,22,132,9,2,13,6,21,21,98,121,116,101,32,
-115,116,114,105,110,103,32,111,114,32,115,116,114,105,110,103,196,28,28,248,22,
-74,195,249,22,4,22,139,13,196,11,12,250,22,132,9,2,13,6,13,13,108,
-105,115,116,32,111,102,32,112,97,116,104,115,197,250,2,47,197,195,28,248,22,
-159,6,197,248,22,170,7,197,196,32,50,89,162,8,44,39,57,2,18,222,33,
-53,32,51,89,162,8,44,38,54,70,102,111,117,110,100,45,101,120,101,99,222,
-33,52,28,23,193,2,91,159,38,11,90,161,38,35,11,248,22,160,13,23,199,
-2,87,95,23,195,1,23,194,1,27,28,23,198,2,27,248,22,165,13,23,201,
-2,28,249,22,166,8,23,195,2,23,202,2,11,28,248,22,161,13,23,194,2,
-250,2,51,23,201,2,23,202,2,249,22,157,13,23,200,2,23,198,1,250,2,
-51,23,201,2,23,202,2,23,196,1,11,28,23,193,2,192,87,94,23,193,1,
-27,28,248,22,139,13,23,196,2,27,249,22,157,13,23,198,2,23,201,2,28,
-28,248,22,152,13,193,10,248,22,151,13,193,192,11,11,28,23,193,2,192,87,
-94,23,193,1,28,23,199,2,11,27,248,22,165,13,23,202,2,28,249,22,166,
-8,23,195,2,23,203,1,11,28,248,22,161,13,23,194,2,250,2,51,23,202,
-1,23,203,1,249,22,157,13,23,201,1,23,198,1,250,2,51,201,202,195,194,
-28,248,22,73,23,197,2,11,27,248,22,164,13,248,22,66,23,199,2,27,249,
-22,157,13,23,196,1,23,197,2,28,248,22,151,13,23,194,2,250,2,51,198,
-199,195,87,94,23,193,1,27,248,22,67,23,200,1,28,248,22,73,23,194,2,
-11,27,248,22,164,13,248,22,66,23,196,2,27,249,22,157,13,23,196,1,23,
-200,2,28,248,22,151,13,23,194,2,250,2,51,201,202,195,87,94,23,193,1,
-27,248,22,67,23,197,1,28,248,22,73,23,194,2,11,27,248,22,164,13,248,
-22,66,195,27,249,22,157,13,23,196,1,202,28,248,22,151,13,193,250,2,51,
-204,205,195,251,2,50,204,205,206,248,22,67,199,87,95,28,27,248,22,139,13,
-23,196,2,28,23,193,2,192,87,94,23,193,1,28,248,22,159,6,23,196,2,
-27,248,22,161,13,23,197,2,28,23,193,2,192,87,94,23,193,1,248,22,162,
-13,23,197,2,11,12,250,22,132,9,2,14,6,25,25,112,97,116,104,32,111,
-114,32,115,116,114,105,110,103,32,40,115,97,110,115,32,110,117,108,41,23,197,
-2,28,28,23,195,2,28,27,248,22,139,13,23,197,2,28,23,193,2,192,87,
-94,23,193,1,28,248,22,159,6,23,197,2,27,248,22,161,13,23,198,2,28,
-23,193,2,192,87,94,23,193,1,248,22,162,13,23,198,2,11,248,22,161,13,
-23,196,2,11,10,12,250,22,132,9,2,14,6,29,29,35,102,32,111,114,32,
-114,101,108,97,116,105,118,101,32,112,97,116,104,32,111,114,32,115,116,114,105,
-110,103,23,198,2,28,28,248,22,161,13,23,195,2,91,159,38,11,90,161,38,
-35,11,248,22,160,13,23,198,2,249,22,164,8,194,68,114,101,108,97,116,105,
-118,101,11,27,248,22,176,7,6,4,4,80,65,84,72,251,2,50,23,199,1,
-23,200,1,23,201,1,28,23,197,2,27,249,80,159,43,47,37,23,200,1,9,
-28,249,22,164,8,247,22,178,7,2,20,249,22,65,248,22,148,13,5,1,46,
-23,195,1,192,9,27,248,22,164,13,23,196,1,28,248,22,151,13,193,250,2,
-51,198,199,195,11,250,80,158,38,48,196,197,11,250,80,158,38,48,196,11,11,
-87,94,249,22,150,6,247,22,186,4,195,248,22,176,5,249,22,172,3,35,249,
-22,156,3,197,198,27,28,23,197,2,87,95,23,196,1,23,195,1,23,197,1,
-87,94,23,197,1,27,248,22,178,13,2,19,27,249,80,159,40,48,37,23,196,
-1,11,27,27,248,22,175,3,23,200,1,28,192,192,35,27,27,248,22,175,3,
-23,202,1,28,192,192,35,249,22,153,5,23,197,1,83,158,39,20,97,95,89,
-162,8,44,35,47,9,224,3,2,33,57,23,195,1,23,196,1,27,248,22,138,
-5,23,195,1,248,80,159,38,53,36,193,159,35,20,103,159,35,16,1,11,16,
-0,83,158,41,20,100,143,67,35,37,117,116,105,108,115,29,11,11,11,11,10,
-10,42,80,158,35,35,20,103,159,37,16,17,2,1,2,2,2,3,2,4,2,
-5,2,6,2,7,2,8,2,9,2,10,2,11,2,12,2,13,2,14,2,15,
-30,2,17,1,20,112,97,114,97,109,101,116,101,114,105,122,97,116,105,111,110,
-45,107,101,121,4,30,2,17,1,23,101,120,116,101,110,100,45,112,97,114,97,
-109,101,116,101,114,105,122,97,116,105,111,110,3,16,0,11,11,16,0,35,16,
-0,35,16,4,2,5,2,4,2,2,2,8,39,11,11,38,35,11,11,16,11,
-2,7,2,6,2,15,2,14,2,12,2,11,2,3,2,10,2,13,2,9,2,
-1,16,11,11,11,11,11,11,11,11,11,11,11,11,16,11,2,7,2,6,2,
-15,2,14,2,12,2,11,2,3,2,10,2,13,2,9,2,1,46,46,36,11,
-11,16,0,16,0,16,0,35,35,11,11,11,16,0,16,0,16,0,35,35,16,
-0,16,17,83,158,35,16,2,89,162,43,36,48,2,18,223,0,33,28,80,159,
-35,53,36,83,158,35,16,2,89,162,8,44,36,55,2,18,223,0,33,29,80,
-159,35,52,36,83,158,35,16,2,32,0,89,162,43,36,44,2,1,222,33,30,
-80,159,35,35,36,83,158,35,16,2,249,22,161,6,7,92,7,92,80,159,35,
-36,36,83,158,35,16,2,89,162,43,36,53,2,3,223,0,33,31,80,159,35,
-37,36,83,158,35,16,2,32,0,89,162,8,44,37,49,2,4,222,33,32,80,
-159,35,38,36,83,158,35,16,2,32,0,89,162,8,44,38,50,2,5,222,33,
-34,80,159,35,39,36,83,158,35,16,2,89,162,8,45,37,47,2,6,223,0,
-33,36,80,159,35,40,36,83,158,35,16,2,32,0,89,162,43,39,51,2,7,
-222,33,39,80,159,35,41,36,83,158,35,16,2,32,0,89,162,43,38,49,2,
-8,222,33,40,80,159,35,42,36,83,158,35,16,2,32,0,89,162,43,37,52,
-2,9,222,33,41,80,159,35,43,36,83,158,35,16,2,32,0,89,162,43,37,
-53,2,10,222,33,42,80,159,35,44,36,83,158,35,16,2,32,0,89,162,43,
-36,43,2,11,222,33,43,80,159,35,45,36,83,158,35,16,2,83,158,38,20,
-96,96,2,12,89,162,43,35,43,9,223,0,33,44,89,162,43,36,44,9,223,
-0,33,45,89,162,43,37,54,9,223,0,33,46,80,159,35,46,36,83,158,35,
-16,2,27,248,22,185,13,248,22,170,7,27,28,249,22,164,8,247,22,178,7,
-2,20,6,1,1,59,6,1,1,58,250,22,143,7,6,14,14,40,91,94,126,
-97,93,42,41,126,97,40,46,42,41,23,196,2,23,196,1,89,162,8,44,37,
-47,2,13,223,0,33,49,80,159,35,47,36,83,158,35,16,2,83,158,38,20,
-96,96,2,14,89,162,8,44,38,53,9,223,0,33,54,89,162,43,37,46,9,
-223,0,33,55,89,162,43,36,45,9,223,0,33,56,80,159,35,48,36,83,158,
-35,16,2,89,162,43,38,51,2,15,223,0,33,58,80,159,35,49,36,94,29,
-94,2,16,68,35,37,107,101,114,110,101,108,11,29,94,2,16,69,35,37,109,
-105,110,45,115,116,120,11,9,9,9,35,0};
-    EVAL_ONE_SIZED_STR((char *)expr, 5009);
-  }
-  {
-    static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,49,46,52,46,50,8,0,0,0,1,0,0,6,0,19,0,
-34,0,48,0,62,0,76,0,111,0,0,0,1,1,0,0,65,113,117,111,116,
-101,29,94,2,1,67,35,37,117,116,105,108,115,11,29,94,2,1,69,35,37,
-110,101,116,119,111,114,107,11,29,94,2,1,68,35,37,112,97,114,97,109,122,
-11,29,94,2,1,68,35,37,101,120,112,111,98,115,11,29,94,2,1,68,35,
-37,107,101,114,110,101,108,11,98,10,35,11,8,140,230,97,159,2,2,35,35,
-159,2,3,35,35,159,2,4,35,35,159,2,5,35,35,159,2,6,35,35,16,
-0,159,35,20,103,159,35,16,1,11,16,0,83,158,41,20,100,143,69,35,37,
-98,117,105,108,116,105,110,29,11,11,11,10,10,18,96,11,42,42,42,35,80,
-158,35,35,20,103,159,35,16,0,16,0,11,11,16,0,35,16,0,35,16,0,
-35,11,11,38,35,11,11,16,0,16,0,16,0,35,35,36,11,11,16,0,16,
-0,16,0,35,35,11,11,11,16,0,16,0,16,0,35,35,16,0,16,0,99,
-2,6,2,5,29,94,2,1,69,35,37,102,111,114,101,105,103,110,11,2,4,
-2,3,2,2,29,94,2,1,67,35,37,112,108,97,99,101,11,9,9,9,35,
-0};
-    EVAL_ONE_SIZED_STR((char *)expr, 294);
-  }
-  {
-    static MZCOMPILED_STRING_FAR unsigned char expr[] = {35,126,7,52,46,49,46,52,46,50,52,0,0,0,1,0,0,11,0,38,0,
-44,0,57,0,71,0,93,0,119,0,131,0,149,0,169,0,181,0,197,0,220,
-0,0,1,5,1,10,1,15,1,24,1,29,1,60,1,64,1,72,1,81,1,
-89,1,196,1,241,1,5,2,34,2,65,2,121,2,131,2,178,2,188,2,195,
-2,82,4,95,4,114,4,233,4,245,4,141,5,155,5,21,6,27,6,41,6,
-68,6,153,6,155,6,221,6,166,12,225,12,3,13,0,0,138,15,0,0,70,
-100,108,108,45,115,117,102,102,105,120,1,25,100,101,102,97,117,108,116,45,108,
-111,97,100,47,117,115,101,45,99,111,109,112,105,108,101,100,65,113,117,111,116,
-101,29,94,2,3,67,35,37,117,116,105,108,115,11,29,94,2,3,68,35,37,
-112,97,114,97,109,122,11,1,20,100,101,102,97,117,108,116,45,114,101,97,100,
-101,114,45,103,117,97,114,100,1,24,45,109,111,100,117,108,101,45,104,97,115,
-104,45,116,97,98,108,101,45,116,97,98,108,101,71,45,112,97,116,104,45,99,
-97,99,104,101,77,45,108,111,97,100,105,110,103,45,102,105,108,101,110,97,109,
-101,79,45,108,111,97,100,105,110,103,45,112,114,111,109,112,116,45,116,97,103,
-71,45,112,114,101,118,45,114,101,108,116,111,75,45,112,114,101,118,45,114,101,
-108,116,111,45,100,105,114,1,21,115,112,108,105,116,45,114,101,108,97,116,105,
-118,101,45,115,116,114,105,110,103,1,34,109,97,107,101,45,115,116,97,110,100,
-97,114,100,45,109,111,100,117,108,101,45,110,97,109,101,45,114,101,115,111,108,
-118,101,114,64,98,111,111,116,64,115,97,109,101,5,3,46,122,111,6,6,6,
-110,97,116,105,118,101,64,108,111,111,112,1,29,115,116,97,110,100,97,114,100,
-45,109,111,100,117,108,101,45,110,97,109,101,45,114,101,115,111,108,118,101,114,
-63,108,105,98,67,105,103,110,111,114,101,100,249,22,14,195,80,159,37,45,37,
-249,80,159,37,48,36,195,10,27,28,23,195,2,28,249,22,164,8,23,197,2,
-80,159,38,46,37,87,94,23,195,1,80,159,36,47,37,27,248,22,173,4,23,
-197,2,28,248,22,139,13,23,194,2,91,159,38,11,90,161,38,35,11,248,22,
-160,13,23,197,1,87,95,83,160,37,11,80,159,40,46,37,198,83,160,37,11,
-80,159,40,47,37,192,192,11,11,28,23,193,2,192,87,94,23,193,1,27,247,
-22,191,4,28,192,192,247,22,179,13,20,14,159,80,158,35,39,250,80,158,38,
-40,249,22,27,11,80,158,40,39,22,191,4,28,248,22,139,13,23,198,2,23,
-197,1,87,94,23,197,1,247,22,179,13,247,194,250,22,157,13,23,197,1,23,
-199,1,249,80,158,42,38,23,198,1,2,17,252,22,157,13,23,199,1,23,201,
-1,2,18,247,22,179,7,249,80,158,44,38,23,200,1,80,159,44,35,37,87,
-94,23,194,1,27,250,22,174,13,196,11,32,0,89,162,8,44,35,40,9,222,
-11,28,192,249,22,65,195,194,11,27,252,22,157,13,23,200,1,23,202,1,2,
-18,247,22,179,7,249,80,158,45,38,23,201,1,80,159,45,35,37,27,250,22,
-174,13,196,11,32,0,89,162,8,44,35,40,9,222,11,28,192,249,22,65,195,
-194,11,249,247,22,184,13,248,22,66,195,195,27,250,22,157,13,23,198,1,23,
-200,1,249,80,158,43,38,23,199,1,2,17,27,250,22,174,13,196,11,32,0,
-89,162,8,44,35,40,9,222,11,28,192,249,22,65,195,194,11,249,247,22,189,
-4,248,22,66,195,195,249,247,22,189,4,194,195,87,94,28,248,80,158,36,37,
-23,195,2,12,250,22,132,9,77,108,111,97,100,47,117,115,101,45,99,111,109,
-112,105,108,101,100,6,25,25,112,97,116,104,32,111,114,32,118,97,108,105,100,
-45,112,97,116,104,32,115,116,114,105,110,103,23,197,2,91,159,41,11,90,161,
-36,35,11,28,248,22,163,13,23,201,2,23,200,1,27,247,22,191,4,28,23,
-193,2,249,22,164,13,23,203,1,23,195,1,200,90,161,38,36,11,248,22,160,
-13,23,194,2,87,94,23,196,1,90,161,36,39,11,28,249,22,164,8,23,196,
-2,68,114,101,108,97,116,105,118,101,87,94,23,194,1,2,16,23,194,1,90,
-161,36,40,11,247,22,181,13,27,89,162,43,36,49,62,122,111,225,7,5,3,
-33,27,27,89,162,43,36,51,9,225,8,6,4,33,28,27,249,22,5,89,162,
-8,44,36,46,9,223,5,33,29,23,203,2,27,28,23,195,1,27,249,22,5,
-89,162,8,44,36,52,9,225,13,11,9,33,30,23,205,2,27,28,23,196,2,
-11,193,28,192,192,28,193,28,23,196,2,28,249,22,168,3,248,22,67,196,248,
-22,67,23,199,2,193,11,11,11,11,28,23,193,2,249,80,159,47,54,36,202,
-89,162,43,35,45,9,224,14,2,33,31,87,94,23,193,1,27,28,23,197,1,
-27,249,22,5,83,158,39,20,97,94,89,162,8,44,36,50,9,225,14,12,10,
-33,32,23,203,1,23,206,1,27,28,196,11,193,28,192,192,28,193,28,196,28,
-249,22,168,3,248,22,67,196,248,22,67,199,193,11,11,11,11,28,192,249,80,
-159,48,54,36,203,89,162,43,35,45,9,224,15,2,33,33,249,80,159,48,54,
-36,203,89,162,43,35,44,9,224,15,7,33,34,32,36,89,162,8,44,36,54,
-2,19,222,33,38,0,17,35,114,120,34,94,40,46,42,63,41,47,40,46,42,
-41,36,34,27,249,22,189,13,2,37,23,196,2,28,23,193,2,87,94,23,194,
-1,249,22,65,248,22,90,23,196,2,27,248,22,99,23,197,1,27,249,22,189,
-13,2,37,23,196,2,28,23,193,2,87,94,23,194,1,249,22,65,248,22,90,
-23,196,2,27,248,22,99,23,197,1,27,249,22,189,13,2,37,23,196,2,28,
-23,193,2,87,94,23,194,1,249,22,65,248,22,90,23,196,2,248,2,36,248,
-22,99,23,197,1,248,22,75,194,248,22,75,194,248,22,75,194,32,39,89,162,
-43,36,54,2,19,222,33,40,28,248,22,73,248,22,67,23,195,2,249,22,7,
-9,248,22,66,195,91,159,37,11,90,161,37,35,11,27,248,22,67,23,197,2,
-28,248,22,73,248,22,67,23,195,2,249,22,7,9,248,22,66,195,91,159,37,
-11,90,161,37,35,11,27,248,22,67,23,197,2,28,248,22,73,248,22,67,23,
-195,2,249,22,7,9,248,22,66,195,91,159,37,11,90,161,37,35,11,248,2,
-39,248,22,67,23,197,2,249,22,7,249,22,65,248,22,66,23,200,1,23,197,
-1,195,249,22,7,249,22,65,248,22,66,23,200,1,23,197,1,195,249,22,7,
-249,22,65,248,22,66,23,200,1,23,197,1,195,27,248,2,36,23,195,1,28,
-194,192,248,2,39,193,87,95,28,248,22,171,4,195,12,250,22,132,9,2,20,
-6,20,20,114,101,115,111,108,118,101,100,45,109,111,100,117,108,101,45,112,97,
-116,104,197,28,24,193,2,248,24,194,1,195,87,94,23,193,1,12,27,27,250,
-22,139,2,80,159,41,42,37,248,22,145,14,247,22,186,11,11,28,23,193,2,
-192,87,94,23,193,1,27,247,22,123,87,94,250,22,137,2,80,159,42,42,37,
-248,22,145,14,247,22,186,11,195,192,250,22,137,2,195,198,66,97,116,116,97,
-99,104,251,211,197,198,199,10,28,192,250,22,131,9,11,196,195,248,22,129,9,
-194,28,249,22,165,6,194,6,1,1,46,2,16,28,249,22,165,6,194,6,2,
-2,46,46,62,117,112,192,28,249,22,166,8,248,22,67,23,200,2,23,197,1,
-28,249,22,164,8,248,22,66,23,200,2,23,196,1,251,22,129,9,2,20,6,
-26,26,99,121,99,108,101,32,105,110,32,108,111,97,100,105,110,103,32,97,116,
-32,126,101,58,32,126,101,23,200,1,249,22,2,22,67,248,22,80,249,22,65,
-23,206,1,23,202,1,12,12,247,192,20,14,159,80,159,39,44,37,249,22,65,
-248,22,145,14,247,22,186,11,23,197,1,20,14,159,80,158,39,39,250,80,158,
-42,40,249,22,27,11,80,158,44,39,22,153,4,23,196,1,249,247,22,190,4,
-23,198,1,248,22,54,248,22,143,13,23,198,1,87,94,28,28,248,22,139,13,
-23,197,2,10,248,22,177,4,23,197,2,12,28,23,198,2,250,22,131,9,11,
-6,15,15,98,97,100,32,109,111,100,117,108,101,32,112,97,116,104,23,201,2,
-250,22,132,9,2,20,6,19,19,109,111,100,117,108,101,45,112,97,116,104,32,
-111,114,32,112,97,116,104,23,199,2,28,28,248,22,63,23,197,2,249,22,164,
-8,248,22,66,23,199,2,2,3,11,248,22,172,4,248,22,90,197,28,28,248,
-22,63,23,197,2,249,22,164,8,248,22,66,23,199,2,66,112,108,97,110,101,
-116,11,87,94,28,207,12,20,14,159,80,158,37,39,250,80,158,40,40,249,22,
-27,11,80,158,42,39,22,186,11,23,197,1,90,161,36,35,10,249,22,154,4,
-21,94,2,21,6,18,18,112,108,97,110,101,116,47,114,101,115,111,108,118,101,
-114,46,115,115,1,27,112,108,97,110,101,116,45,109,111,100,117,108,101,45,110,
-97,109,101,45,114,101,115,111,108,118,101,114,12,251,211,199,200,201,202,87,94,
-23,193,1,27,89,162,8,44,36,45,79,115,104,111,119,45,99,111,108,108,101,
-99,116,105,111,110,45,101,114,114,223,6,33,44,27,28,248,22,53,23,199,2,
-27,250,22,139,2,80,159,43,43,37,249,22,65,23,204,2,247,22,180,13,11,
-28,23,193,2,192,87,94,23,193,1,91,159,37,11,90,161,37,35,11,249,80,
-159,44,48,36,248,22,56,23,204,2,11,27,251,80,158,47,50,2,20,23,202,
-1,28,248,22,73,23,199,2,23,199,2,248,22,66,23,199,2,28,248,22,73,
-23,199,2,9,248,22,67,23,199,2,249,22,157,13,23,195,1,28,248,22,73,
-23,197,1,87,94,23,197,1,6,7,7,109,97,105,110,46,115,115,249,22,182,
-6,23,199,1,6,3,3,46,115,115,28,248,22,159,6,23,199,2,87,94,23,
-194,1,27,248,80,159,41,55,36,23,201,2,27,250,22,139,2,80,159,44,43,
-37,249,22,65,23,205,2,23,199,2,11,28,23,193,2,192,87,94,23,193,1,
-91,159,37,11,90,161,37,35,11,249,80,159,45,48,36,23,204,2,11,250,22,
-1,22,157,13,23,199,1,249,22,79,249,22,2,32,0,89,162,8,44,36,43,
-9,222,33,45,23,200,1,248,22,75,23,200,1,28,248,22,139,13,23,199,2,
-87,94,23,194,1,28,248,22,162,13,23,199,2,23,198,2,248,22,75,6,26,
-26,32,40,97,32,112,97,116,104,32,109,117,115,116,32,98,101,32,97,98,115,
-111,108,117,116,101,41,28,249,22,164,8,248,22,66,23,201,2,2,21,27,250,
-22,139,2,80,159,43,43,37,249,22,65,23,204,2,247,22,180,13,11,28,23,
-193,2,192,87,94,23,193,1,91,159,38,11,90,161,37,35,11,249,80,159,45,
-48,36,248,22,90,23,205,2,11,90,161,36,37,11,28,248,22,73,248,22,92,
-23,204,2,28,248,22,73,23,194,2,249,22,191,13,0,8,35,114,120,34,91,
-46,93,34,23,196,2,11,10,27,27,28,23,197,2,249,22,79,28,248,22,73,
-248,22,92,23,208,2,21,93,6,5,5,109,122,108,105,98,249,22,1,22,79,
-249,22,2,80,159,51,56,36,248,22,92,23,211,2,23,197,2,28,248,22,73,
-23,196,2,248,22,75,23,197,2,23,195,2,251,80,158,49,50,2,20,23,204,
-1,248,22,66,23,198,2,248,22,67,23,198,1,249,22,157,13,23,195,1,28,
-23,198,1,87,94,23,196,1,23,197,1,28,248,22,73,23,197,1,87,94,23,
-197,1,6,7,7,109,97,105,110,46,115,115,28,249,22,191,13,0,8,35,114,
-120,34,91,46,93,34,23,199,2,23,197,1,249,22,182,6,23,199,1,6,3,
-3,46,115,115,28,249,22,164,8,248,22,66,23,201,2,64,102,105,108,101,249,
-22,164,13,248,22,168,13,248,22,90,23,202,2,248,80,159,42,55,36,23,202,
-2,12,87,94,28,28,248,22,139,13,23,194,2,10,248,22,181,7,23,194,2,
-87,94,23,200,1,12,28,23,200,2,250,22,131,9,67,114,101,113,117,105,114,
-101,249,22,143,7,6,17,17,98,97,100,32,109,111,100,117,108,101,32,112,97,
-116,104,126,97,28,23,198,2,248,22,66,23,199,2,6,0,0,23,203,1,87,
-94,23,200,1,250,22,132,9,2,20,249,22,143,7,6,13,13,109,111,100,117,
-108,101,32,112,97,116,104,126,97,28,23,198,2,248,22,66,23,199,2,6,0,
-0,23,201,2,27,28,248,22,181,7,23,195,2,249,22,186,7,23,196,2,35,
-249,22,166,13,248,22,167,13,23,197,2,11,27,28,248,22,181,7,23,196,2,
-249,22,186,7,23,197,2,36,248,80,158,42,51,23,195,2,91,159,38,11,90,
-161,38,35,11,28,248,22,181,7,23,199,2,250,22,7,2,22,249,22,186,7,
-23,203,2,37,2,22,248,22,160,13,23,198,2,87,95,23,195,1,23,193,1,
-27,28,248,22,181,7,23,200,2,249,22,186,7,23,201,2,38,249,80,158,47,
-52,23,197,2,5,0,27,28,248,22,181,7,23,201,2,249,22,186,7,23,202,
-2,39,248,22,172,4,23,200,2,27,27,250,22,139,2,80,159,51,42,37,248,
-22,145,14,247,22,186,11,11,28,23,193,2,192,87,94,23,193,1,27,247,22,
-123,87,94,250,22,137,2,80,159,52,42,37,248,22,145,14,247,22,186,11,195,
-192,87,95,28,23,209,1,27,250,22,139,2,23,197,2,197,11,28,23,193,1,
-12,87,95,27,27,28,248,22,17,80,159,51,45,37,80,159,50,45,37,247,22,
-19,250,22,25,248,22,23,23,197,2,80,159,53,44,37,23,196,1,27,248,22,
-145,14,247,22,186,11,249,22,3,83,158,39,20,97,94,89,162,8,44,36,54,
-9,226,12,11,2,3,33,46,23,195,1,23,196,1,248,28,248,22,17,80,159,
-50,45,37,32,0,89,162,43,36,41,9,222,33,47,80,159,49,57,36,89,162,
-43,35,50,9,227,14,9,8,4,3,33,48,250,22,137,2,23,197,1,197,10,
-12,28,28,248,22,181,7,23,202,1,11,27,248,22,159,6,23,208,2,28,192,
-192,28,248,22,63,23,208,2,249,22,164,8,248,22,66,23,210,2,2,21,11,
-250,22,137,2,80,159,50,43,37,28,248,22,159,6,23,210,2,249,22,65,23,
-211,1,248,80,159,53,55,36,23,213,1,87,94,23,210,1,249,22,65,23,211,
-1,247,22,180,13,252,22,183,7,23,208,1,23,207,1,23,205,1,23,203,1,
-201,12,193,91,159,37,10,90,161,36,35,10,11,90,161,36,36,10,83,158,38,
-20,96,96,2,20,89,162,8,44,36,50,9,224,2,0,33,42,89,162,43,38,
-48,9,223,1,33,43,89,162,43,39,8,30,9,225,2,3,0,33,49,208,87,
-95,248,22,152,4,248,80,159,37,49,37,247,22,186,11,248,22,190,4,80,159,
-36,36,37,248,22,177,12,80,159,36,41,36,159,35,20,103,159,35,16,1,11,
-16,0,83,158,41,20,100,143,66,35,37,98,111,111,116,29,11,11,11,11,10,
-10,36,80,158,35,35,20,103,159,39,16,19,2,1,2,2,30,2,4,72,112,
-97,116,104,45,115,116,114,105,110,103,63,10,30,2,4,75,112,97,116,104,45,
-97,100,100,45,115,117,102,102,105,120,7,30,2,5,1,20,112,97,114,97,109,
-101,116,101,114,105,122,97,116,105,111,110,45,107,101,121,4,30,2,5,1,23,
-101,120,116,101,110,100,45,112,97,114,97,109,101,116,101,114,105,122,97,116,105,
-111,110,3,2,6,2,7,2,8,2,9,2,10,2,11,2,12,2,13,2,14,
-30,2,4,69,45,102,105,110,100,45,99,111,108,0,30,2,4,76,110,111,114,
-109,97,108,45,99,97,115,101,45,112,97,116,104,6,30,2,4,79,112,97,116,
-104,45,114,101,112,108,97,99,101,45,115,117,102,102,105,120,9,2,15,16,0,
-11,11,16,0,35,16,0,35,16,11,2,9,2,10,2,7,2,8,2,11,2,
-12,2,2,2,6,2,1,2,14,2,13,46,11,11,38,35,11,11,16,1,2,
-15,16,1,11,16,1,2,15,36,36,36,11,11,16,0,16,0,16,0,35,35,
-11,11,11,16,0,16,0,16,0,35,35,16,0,16,16,83,158,35,16,2,89,
-162,43,36,44,9,223,0,33,23,80,159,35,57,36,83,158,35,16,2,89,162,
-43,36,44,9,223,0,33,24,80,159,35,56,36,83,158,35,16,2,89,162,43,
-36,48,67,103,101,116,45,100,105,114,223,0,33,25,80,159,35,55,36,83,158,
-35,16,2,89,162,43,37,48,68,119,105,116,104,45,100,105,114,223,0,33,26,
-80,159,35,54,36,83,158,35,16,2,248,22,178,7,69,115,111,45,115,117,102,
-102,105,120,80,159,35,35,36,83,158,35,16,2,89,162,43,37,59,2,2,223,
-0,33,35,80,159,35,36,36,83,158,35,16,2,32,0,89,162,8,44,36,41,
-2,6,222,192,80,159,35,41,36,83,158,35,16,2,247,22,126,80,159,35,42,
-36,83,158,35,16,2,247,22,125,80,159,35,43,36,83,158,35,16,2,247,22,
-61,80,159,35,44,36,83,158,35,16,2,248,22,18,74,109,111,100,117,108,101,
-45,108,111,97,100,105,110,103,80,159,35,45,36,83,158,35,16,2,11,80,158,
-35,46,83,158,35,16,2,11,80,158,35,47,83,158,35,16,2,32,0,89,162,
-43,37,44,2,13,222,33,41,80,159,35,48,36,83,158,35,16,2,89,162,8,
-44,36,44,2,14,223,0,33,50,80,159,35,49,36,83,158,35,16,2,89,162,
-43,35,43,2,15,223,0,33,51,80,159,35,53,36,95,29,94,2,3,68,35,
-37,107,101,114,110,101,108,11,29,94,2,3,69,35,37,109,105,110,45,115,116,
-120,11,2,4,9,9,9,35,0};
-    EVAL_ONE_SIZED_STR((char *)expr, 4103);
-  }
-------------- next part --------------
#lang scheme
(require srfi/78)
(provide async test-async 
         tagged test-tags 
         my-thread my-thread? test-my-thread
         run-tests)

(define (async thunk)
  (let ((thr (thread
              (lambda ()
                (with-handlers ((void (lambda (e) (thread-set-specific! e))))
                  (thread-set-specific! (thunk)))))))
    (handle-evt thr (lambda (thr) (thread-get-specific thr)))))

(define (a1) 1)
(define (a2) (error 'a2))

(define (test-async)
  (check (sync (async a1)) => 1)
  (let ((v2 (sync (async a2))))
    (check (exn? v2) => #t)))

(define (tagged . fs)
  (thread 
   (lambda () 
     (for ((f fs))
       (thread-set-specific! (object-name (car f)))
       (apply (car f) (cdr f))))))

(define (b1 sema) (semaphore-wait sema))
(define (b2 sema) (semaphore-wait sema))
(define (b3 sema) (semaphore-wait sema))

(define (test-tags)
  (let* ((semas (build-list 3 (lambda (i) (make-semaphore))))
         (acts (for/list ((f (list b1 b2 b3)) (s semas)) (list f s)))
         (tag (apply tagged acts)))
    (for ((state acts))
      (sync (system-idle-evt))
      (check (thread-get-specific tag) => (object-name (car state)))
      (semaphore-post (cadr state)))
    (thread-wait tag)))
    
(define (my-thread thunk mark)
  (let* ((sema (make-semaphore))
         (thr (thread
               (lambda () 
                 (thread-set-specific! mark) 
                 (semaphore-post sema) 
                 (thunk)))))
    (semaphore-wait sema)
    thr))

(define (my-thread? thr mark)
  (eq? (thread-get-specific thr) mark))

(define (test-my-thread)
  (let ((mark #&me))
    (check (my-thread? (thread void) mark) => #f)
    (check (my-thread? (my-thread void mark) mark) => #t)))

(define (run-tests)
  (test-async)
  (test-tags)
  (test-my-thread))

  

Posted on the dev mailing list.