Esempio n. 1
0
void do_work(chaiscript::ChaiScript &c)
{
//  c("use(\"work.chai\"); do_chai_work(num_iterations);"); 
  std::string name = "MyVar" + boost::lexical_cast<std::string>(rand());
  c.add(chaiscript::var(5), name);
  c("use(\"work.chai\"); do_chai_work(10000);");
}
void do_work(chaiscript::ChaiScript &c, int id)
{
  try{
    std::stringstream ss;
    ss << "MyVar" << rand();
    c.add(chaiscript::var(5), ss.str());
    ss.str("");
    ss << id;
    c.use("multithreaded_work.inc");
    c("do_chai_work(4000, " + ss.str() + ");");
  } catch (const std::exception &e) {
    std::cout << "exception: " << e.what() << " thread:  " << id;
  }
}
Esempio n. 3
0
 void ResetState()
 {
   chai.set_state(backupState);
   chai.add(chaiscript::fun(&function),"Whatever()");
 }