green-threads: add thread and continuation objects to the type system
authorDaniel Kochmański <daniel@turtleware.eu>
Mon, 24 Aug 2015 11:37:35 +0000 (13:37 +0200)
committerDaniel Kochmański <daniel@turtleware.eu>
Mon, 24 Aug 2015 14:02:22 +0000 (16:02 +0200)
This step involves adding types to typespec.d, object.h, instance.d
and printer.d modules and enlisting them at symbols_list.h.

Signed-off-by: Daniel Kochmański <daniel@turtleware.eu>
src/c/instance.d
src/c/printer/write_ugly.d
src/c/symbols_list.h
src/c/symbols_list2.h
src/c/typespec.d
src/h/object.h

index 6209e2b..c5d132f 100644 (file)
@@ -272,6 +272,11 @@ enum ecl_built_in_classes {
         ECL_BUILTIN_FOREIGN_DATA,
         ECL_BUILTIN_FRAME,
         ECL_BUILTIN_WEAK_POINTER
+#ifdef ECL_LWP
+        ,
+        ECL_BUILTIN_CONTINUATION,
+        ECL_BUILTIN_THREAD
+#endif
 #ifdef ECL_THREADS
         ,
         ECL_BUILTIN_PROCESS,
@@ -366,6 +371,12 @@ cl_class_of(cl_object x)
         case t_cfunfixed:
         case t_cclosure:
                 index = ECL_BUILTIN_FUNCTION; break;
+#ifdef ECL_LWP                  /* XXX */
+        case t_cont:
+                index = ECL_BUILTIN_CONTINUATION; break;
+        case t_thread:
+                index = ECL_BUILTIN_THREAD; break;
+#endif
 #ifdef ECL_THREADS
         case t_process:
                 index = ECL_BUILTIN_PROCESS; break;
index f882580..b7db584 100644 (file)
@@ -347,6 +347,20 @@ write_weak_pointer(cl_object x, cl_object stream)
         _ecl_write_unreadable(x, "weak-pointer", ECL_NIL, stream);
 }
 
+#ifdef ECL_LWP
+static void
+write_cont(cl_object x, cl_object stream)
+{
+        _ecl_write_unreadable(x, "continuation", ECL_NIL, stream);
+}
+
+static void
+write_thread(cl_object x, cl_object stream)
+{
+        _ecl_write_unreadable(x, "thread", ECL_NIL, stream);
+}
+#endif
+
 #ifdef ECL_THREADS
 static void
 write_process(cl_object x, cl_object stream)
@@ -430,6 +444,8 @@ static printer dispatch[FREE+1] = {
         write_cfun, /* t_cfunfixed */
         write_cclosure, /* t_cclosure */
         write_instance, /* t_instance */
+        write_cont,     /* t_cont */
+        write_thread,   /* t_thread */
 #ifdef ECL_THREADS
         write_process, /* t_process */
         write_lock, /* t_lock */
index ee6a864..df34863 100755 (executable)
@@ -1531,6 +1531,9 @@ cl_symbols[] = {
 #endif /* !GBC_BOEHM */
 
 #ifdef ECL_LWP
+{EXT_ "CONT", EXT_ORDINARY, NULL, -1, OBJNULL},
+{EXT_ "THREAD", EXT_ORDINARY, NULL, -1, OBJNULL},
+
 {EXT_ "MAKE-THREAD", EXT_ORDINARY, NULL, -1, OBJNULL},
 {EXT_ "DEACTIVATE", EXT_ORDINARY, NULL, -1, OBJNULL},
 {EXT_ "REACTIVATE", EXT_ORDINARY, NULL, -1, OBJNULL},
index 2d2e035..7429634 100644 (file)
@@ -1531,6 +1531,9 @@ cl_symbols[] = {
 #endif /* !GBC_BOEHM */
 
 #ifdef ECL_LWP
+{EXT_ "CONT",NULL},
+{EXT_ "THREAD",NULL},
+
 {EXT_ "MAKE-THREAD",NULL},
 {EXT_ "DEACTIVATE",NULL},
 {EXT_ "REACTIVATE",NULL},
index d10dfd2..76ef2fd 100644 (file)
@@ -156,6 +156,12 @@ ecl_type_to_symbol(cl_type t)
         case t_cfunfixed:
         case t_cclosure:
                 return @'compiled-function';
+#ifdef ECL_LWP
+        case t_cont:
+                return @'ext::cont';
+        case t_thread:
+                return @'ext::thread';
+#endif
 #ifdef ECL_THREADS
         case t_process:
                 return @'mp::process';
index ac541bf..5b41157 100644 (file)
@@ -74,6 +74,10 @@ typedef enum {
         t_cclosure,
         t_instance,
         t_structure = t_instance,
+#ifdef ECL_LWP
+        t_cont,
+        t_thread,
+#endif
 #ifdef ECL_THREADS
         t_process,
         t_lock,
@@ -847,6 +851,18 @@ struct ecl_dummy {
         _ECL_HDR;
 };
 
+#ifdef ECL_LWP
+struct ecl_cont {
+        _ECL_HDR2(resumed, timed_out);
+        cl_object thread;
+};
+
+struct ecl_thread {
+        _ECL_HDR;
+        cl_object  cont;           /* its continuation */
+};
+#endif /* ECL_LWP */
+
 #ifdef ECL_THREADS
 enum {
         ECL_PROCESS_INACTIVE = 0,
@@ -1036,6 +1052,10 @@ union cl_lispunion {
         struct ecl_cclosure     cclosure;       /*  compiled closure  */
         struct ecl_dummy        d;              /*  dummy  */
         struct ecl_instance     instance;       /*  clos instance */
+#ifdef ECL_LWP
+        struct ecl_cont         cont;           /* continuation */
+        struct ecl_thread       thread;         /* thread  */
+#endif
 #ifdef ECL_THREADS
         struct ecl_process      process;        /*  process  */
         struct ecl_queue        queue;          /*  queue  */