mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
some update
This commit is contained in:
parent
ded75de379
commit
d53cd8e956
@ -11,6 +11,7 @@ using namespace pkpy;
|
||||
|
||||
class MyVM: public VM{
|
||||
public:
|
||||
// use atomic to protect the flag
|
||||
std::atomic<bool> _flag = false;
|
||||
|
||||
MyVM(): VM(){
|
||||
@ -43,12 +44,15 @@ int main(){
|
||||
std::cout << (need_more_lines ? "... " : ">>> ");
|
||||
std::string line;
|
||||
std::getline(std::cin, line);
|
||||
|
||||
vm->_flag = false; // reset the flag before each input
|
||||
|
||||
// here I use linux signal to interrupt the vm
|
||||
// you can run this line in a thread for more flexibility
|
||||
need_more_lines = repl->input(line);
|
||||
}
|
||||
|
||||
delete repl;
|
||||
delete vm;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,15 +3,11 @@
|
||||
/*************** feature settings ***************/
|
||||
|
||||
// Whether to compile os-related modules or not
|
||||
#ifndef PK_ENABLE_OS // can be overrided by cmake
|
||||
#define PK_ENABLE_OS 1
|
||||
#endif
|
||||
|
||||
// Enable this if you are working with multi-threading (experimental)
|
||||
// This triggers necessary locks to make the VM thread-safe
|
||||
#ifndef PK_ENABLE_THREAD // can be overrided by cmake
|
||||
#define PK_ENABLE_THREAD 0
|
||||
#endif
|
||||
#define PK_ENABLE_THREAD 1
|
||||
|
||||
// Enable this for `vm->_ceval_on_step`
|
||||
#define PK_ENABLE_CEVAL_CALLBACK 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user