66#include < scratchcpp/executioncontext.h>
77
88#include " thread_p.h"
9- #include " scratch/string_pool_p.h"
109
1110using namespace libscratchcpp ;
1211
1312/* ! Constructs Thread. */
1413Thread::Thread (Target *target, IEngine *engine, Script *script) :
1514 impl(spimpl::make_unique_impl<ThreadPrivate>(target, engine, script))
1615{
17- string_pool_add_thread (this );
18-
1916 if (impl->script ) {
2017 impl->code = impl->script ->code ();
2118 impl->hatPredicateCode = impl->script ->hatPredicateCode ();
@@ -28,12 +25,6 @@ Thread::Thread(Target *target, IEngine *engine, Script *script) :
2825 }
2926}
3027
31- /* ! Destroys Thread. */
32- Thread::~Thread ()
33- {
34- string_pool_remove_thread (this );
35- }
36-
3728/* ! Returns the Target of the script. */
3829Target *Thread::target () const
3930{
@@ -55,17 +46,13 @@ Script *Thread::script() const
5546/* ! Runs the script until it finishes or yields. */
5647void Thread::run ()
5748{
58- string_pool_set_thread (this );
5949 impl->code ->run (impl->executionContext .get ());
60- string_pool_set_thread (nullptr );
6150}
6251
6352/* ! Runs the reporter and returns its return value. */
6453ValueData Thread::runReporter ()
6554{
66- string_pool_set_thread (this );
6755 ValueData ret = impl->code ->runReporter (impl->executionContext .get ());
68- string_pool_set_thread (nullptr );
6956 return ret;
7057}
7158
@@ -75,9 +62,7 @@ bool Thread::runPredicate()
7562 if (!impl->hatPredicateCode )
7663 return false ;
7764
78- string_pool_set_thread (this );
7965 const bool ret = impl->hatPredicateCode ->runPredicate (impl->hatPredicateExecutionContext .get ());
80- string_pool_set_thread (nullptr );
8166 return ret;
8267}
8368
0 commit comments