From 8ceeb5f83f22ed3db06fc02bb23710ccc1dbbb90 Mon Sep 17 00:00:00 2001 From: olpc user Date: Mon, 9 Dec 2019 03:26:04 -0800 Subject: use tls contexts for habits --- starts/meaning-vm/level-2/common.hpp | 9 +++++++++ starts/meaning-vm/level-2/funcs.cpp | 9 ++++++--- starts/meaning-vm/level-2/sugar.hpp | 8 ++++---- 3 files changed, 19 insertions(+), 7 deletions(-) (limited to 'starts/meaning-vm/level-2') diff --git a/starts/meaning-vm/level-2/common.hpp b/starts/meaning-vm/level-2/common.hpp index 6f70f09..aac072e 100644 --- a/starts/meaning-vm/level-2/common.hpp +++ b/starts/meaning-vm/level-2/common.hpp @@ -1 +1,10 @@ #pragma once + +namespace intellect { +namespace level2 { + +template struct baseref; +struct ref; + +} +} diff --git a/starts/meaning-vm/level-2/funcs.cpp b/starts/meaning-vm/level-2/funcs.cpp index 4ee02a4..c25ead2 100644 --- a/starts/meaning-vm/level-2/funcs.cpp +++ b/starts/meaning-vm/level-2/funcs.cpp @@ -1,13 +1,16 @@ -#include "funcs.hp" +#include "funcs.hpp" #include "../level-1/sugar.hpp" +#include "ref.hpp" + namespace intellect { +using namespace level1; namespace level2 { -level2::ref context() +ref context() { - static thread_local level1::ref ctx = level1::a("context"); + static thread_local auto ctx = a("context"); return ctx; } diff --git a/starts/meaning-vm/level-2/sugar.hpp b/starts/meaning-vm/level-2/sugar.hpp index 3e94c97..6734eae 100644 --- a/starts/meaning-vm/level-2/sugar.hpp +++ b/starts/meaning-vm/level-2/sugar.hpp @@ -11,12 +11,12 @@ #undef self #define ahabit(name, ...) \ a(habit, name); \ - (name).fun((std::function) \ - [=](ref ctx) -> ref\ + (name).fun((std::function) \ + [=]() -> ref\ { \ habitdelay; \ - ref self = name; \ - (void)self; \ + ref self = name; (void)self; \ + ref ctx = intellect::level2::ref::context(); (void) ctx;\ __VA_ARGS__ \ return intellect::level1::concepts::nothing; \ }); -- cgit v1.2.3