From f5f99961c1a51646e8a9cbef3259d0384f81401f Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Fri, 23 Jul 2010 20:00:17 +0000 Subject: [PATCH] Make sure that stack is properly initialized on a per-thread basis. Fixes #95wq --- include/chaiscript/dispatchkit/dispatchkit.hpp | 3 +-- src/multithreaded.cpp | 4 +++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/chaiscript/dispatchkit/dispatchkit.hpp b/include/chaiscript/dispatchkit/dispatchkit.hpp index b28ff25..9c2e5d0 100644 --- a/include/chaiscript/dispatchkit/dispatchkit.hpp +++ b/include/chaiscript/dispatchkit/dispatchkit.hpp @@ -209,8 +209,6 @@ namespace chaiscript Dispatch_Engine() : m_place_holder(boost::shared_ptr(new Placeholder_Object())) { - StackData &stack = get_stack_data(); - stack.get<1>().push_back(Scope()); } ~Dispatch_Engine() @@ -748,6 +746,7 @@ namespace chaiscript Stack_Holder() : stack(new StackData()) { + stack->get<1>().push_back(Scope()); stack->get<2>() = true; } diff --git a/src/multithreaded.cpp b/src/multithreaded.cpp index 07d1e38..ed6f268 100644 --- a/src/multithreaded.cpp +++ b/src/multithreaded.cpp @@ -13,7 +13,9 @@ void do_work(chaiscript::ChaiScript &c) { -// c("use(\"work.chai\"); do_chai_work(num_iterations);"); +// c("use(\"work.chai\"); do_chai_work(num_iterations);"); + std::string name = "MyVar" + boost::lexical_cast(rand()); + c.add(chaiscript::var(5), name); c("use(\"work.chai\"); do_chai_work(10000);"); }