some update

This commit is contained in:
blueloveTH 2023-12-02 13:56:43 +08:00
parent ded75de379
commit d53cd8e956
2 changed files with 5 additions and 5 deletions

View File

@ -11,6 +11,7 @@ using namespace pkpy;
class MyVM: public VM{ class MyVM: public VM{
public: public:
// use atomic to protect the flag
std::atomic<bool> _flag = false; std::atomic<bool> _flag = false;
MyVM(): VM(){ MyVM(): VM(){
@ -43,12 +44,15 @@ int main(){
std::cout << (need_more_lines ? "... " : ">>> "); std::cout << (need_more_lines ? "... " : ">>> ");
std::string line; std::string line;
std::getline(std::cin, line); std::getline(std::cin, line);
vm->_flag = false; // reset the flag before each input vm->_flag = false; // reset the flag before each input
// here I use linux signal to interrupt the vm // here I use linux signal to interrupt the vm
// you can run this line in a thread for more flexibility // you can run this line in a thread for more flexibility
need_more_lines = repl->input(line); need_more_lines = repl->input(line);
} }
delete repl;
delete vm; delete vm;
return 0; return 0;
} }

View File

@ -3,15 +3,11 @@
/*************** feature settings ***************/ /*************** feature settings ***************/
// Whether to compile os-related modules or not // Whether to compile os-related modules or not
#ifndef PK_ENABLE_OS // can be overrided by cmake
#define PK_ENABLE_OS 1 #define PK_ENABLE_OS 1
#endif
// Enable this if you are working with multi-threading (experimental) // Enable this if you are working with multi-threading (experimental)
// This triggers necessary locks to make the VM thread-safe // This triggers necessary locks to make the VM thread-safe
#ifndef PK_ENABLE_THREAD // can be overrided by cmake #define PK_ENABLE_THREAD 1
#define PK_ENABLE_THREAD 0
#endif
// Enable this for `vm->_ceval_on_step` // Enable this for `vm->_ceval_on_step`
#define PK_ENABLE_CEVAL_CALLBACK 1 #define PK_ENABLE_CEVAL_CALLBACK 1