mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-22 12:30:19 +00:00
up
This commit is contained in:
parent
79fd466f1f
commit
075dd44d98
@ -10,7 +10,7 @@ const _Int _Int_MAX_NEG = -9223372036854775807LL;
|
|||||||
const _Float _FLOAT_INF_POS = INFINITY;
|
const _Float _FLOAT_INF_POS = INFINITY;
|
||||||
const _Float _FLOAT_INF_NEG = -INFINITY;
|
const _Float _FLOAT_INF_NEG = -INFINITY;
|
||||||
|
|
||||||
#define PK_VERSION "0.3.6"
|
#define PK_VERSION "0.3.7"
|
||||||
|
|
||||||
class CodeObject;
|
class CodeObject;
|
||||||
class BasePointer;
|
class BasePointer;
|
||||||
|
16
src/vm.h
16
src/vm.h
@ -49,9 +49,19 @@ protected:
|
|||||||
PyVarDict _modules; // loaded modules
|
PyVarDict _modules; // loaded modules
|
||||||
std::map<_Str, _Code> _lazyModules; // lazy loaded modules
|
std::map<_Str, _Code> _lazyModules; // lazy loaded modules
|
||||||
PyVar __py2py_call_signal;
|
PyVar __py2py_call_signal;
|
||||||
|
bool _stopFlag = false;
|
||||||
|
|
||||||
|
void emitKeyboardInterrupt(){
|
||||||
|
_stopFlag = true;
|
||||||
|
}
|
||||||
|
|
||||||
PyVar runFrame(Frame* frame){
|
PyVar runFrame(Frame* frame){
|
||||||
while(!frame->isCodeEnd()){
|
while(!frame->isCodeEnd()){
|
||||||
|
if(_stopFlag){
|
||||||
|
_stopFlag = false;
|
||||||
|
_error("KeyboardInterrupt", "");
|
||||||
|
}
|
||||||
|
|
||||||
const ByteCode& byte = frame->readCode();
|
const ByteCode& byte = frame->readCode();
|
||||||
//printf("%s (%d) stack_size: %d\n", OP_NAMES[byte.op], byte.arg, frame->stackSize());
|
//printf("%s (%d) stack_size: %d\n", OP_NAMES[byte.op], byte.arg, frame->stackSize());
|
||||||
|
|
||||||
@ -1083,7 +1093,6 @@ class ThreadedVM : public VM {
|
|||||||
std::thread* _thread = nullptr;
|
std::thread* _thread = nullptr;
|
||||||
std::atomic<ThreadState> _state = THREAD_READY;
|
std::atomic<ThreadState> _state = THREAD_READY;
|
||||||
std::optional<_Str> _sharedStr = {};
|
std::optional<_Str> _sharedStr = {};
|
||||||
std::atomic<bool> _stopFlag = false;
|
|
||||||
|
|
||||||
PyVar jsonRpc(const _Str& _json){
|
PyVar jsonRpc(const _Str& _json){
|
||||||
_sharedStr = _json;
|
_sharedStr = _json;
|
||||||
@ -1095,9 +1104,8 @@ class ThreadedVM : public VM {
|
|||||||
|
|
||||||
void __deleteThread(){
|
void __deleteThread(){
|
||||||
if(_thread != nullptr){
|
if(_thread != nullptr){
|
||||||
_stopFlag = true;
|
emitKeyboardInterrupt();
|
||||||
_thread->join();
|
_thread->join();
|
||||||
_stopFlag = false;
|
|
||||||
delete _thread;
|
delete _thread;
|
||||||
_thread = nullptr;
|
_thread = nullptr;
|
||||||
}
|
}
|
||||||
@ -1126,7 +1134,7 @@ public:
|
|||||||
_state = THREAD_SUSPENDED;
|
_state = THREAD_SUSPENDED;
|
||||||
// 50 fps is enough
|
// 50 fps is enough
|
||||||
while(_state == THREAD_SUSPENDED){
|
while(_state == THREAD_SUSPENDED){
|
||||||
if(_stopFlag) std::terminate();
|
if(_stopFlag) break;
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
std::this_thread::sleep_for(std::chrono::milliseconds(20));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user