From f456369941f912a053422c8da7b8d6a1fe31e0df Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 Jun 2022 18:15:58 -0500 Subject: [PATCH] Add support for a dyn :task-id Adds extra information to default information from supervisor channels. For threaded channels as supervisors, we don't get the source fiber so identifying the source of messages was not possible. This change allows better multithreading with supervisors. --- CHANGELOG.md | 4 ++++ meson.build | 2 +- src/conf/janetconf.h | 6 +++--- src/core/ev.c | 9 +++++++-- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5857690..ea45911b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All notable changes to this project will be documented in this file. +## 1.23.1 - ??? +- Allow setting `(dyn :task-id)` in fibers to improve context in supervisor messages. Prior to + this change, supverisor messages over threaded channels would be from ambiguous threads/fibers. + ## 1.23.0 - 2022-06-20 - Add experimental `ffi/` module for interfacing with dynamic libraries and raw function pointers. Only available on 64 bit linux, mac, and bsd systems. diff --git a/meson.build b/meson.build index 56adc975..49fc233a 100644 --- a/meson.build +++ b/meson.build @@ -20,7 +20,7 @@ project('janet', 'c', default_options : ['c_std=c99', 'build.c_std=c99', 'b_lundef=false', 'default_library=both'], - version : '1.23.0') + version : '1.23.1') # Global settings janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet') diff --git a/src/conf/janetconf.h b/src/conf/janetconf.h index dff90504..f6e56361 100644 --- a/src/conf/janetconf.h +++ b/src/conf/janetconf.h @@ -5,9 +5,9 @@ #define JANET_VERSION_MAJOR 1 #define JANET_VERSION_MINOR 23 -#define JANET_VERSION_PATCH 0 -#define JANET_VERSION_EXTRA "" -#define JANET_VERSION "1.23.0" +#define JANET_VERSION_PATCH 1 +#define JANET_VERSION_EXTRA "-dev" +#define JANET_VERSION "1.23.1-dev" /* #define JANET_BUILD "local" */ diff --git a/src/core/ev.c b/src/core/ev.c index 6e41131e..bfdb1f1d 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -535,10 +535,15 @@ static int janet_channel_push(JanetChannel *channel, Janet x, int mode); static int janet_channel_pop(JanetChannel *channel, Janet *item, int is_choice); static Janet make_supervisor_event(const char *name, JanetFiber *fiber, int threaded) { - Janet tup[2]; + Janet tup[3]; tup[0] = janet_ckeywordv(name); tup[1] = threaded ? fiber->last_value : janet_wrap_fiber(fiber) ; - return janet_wrap_tuple(janet_tuple_n(tup, 2)); + if (fiber->env != NULL) { + tup[2] = janet_table_get(fiber->env, janet_ckeywordv("task-id")); + } else { + tup[2] = janet_wrap_nil(); + } + return janet_wrap_tuple(janet_tuple_n(tup, 3)); } /* Common init code */