mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 03:20:18 +00:00
...
This commit is contained in:
parent
397123e3c9
commit
205f6ff225
@ -13,12 +13,6 @@
|
||||
#define PK_ENABLE_OS 0
|
||||
#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 overridden by cmake
|
||||
#define PK_ENABLE_THREAD 0
|
||||
#endif
|
||||
|
||||
// Enable `line_profiler` module and `breakpoint()` function
|
||||
#ifndef PK_ENABLE_PROFILER // can be overridden by cmake
|
||||
#define PK_ENABLE_PROFILER 0
|
||||
@ -56,9 +50,3 @@
|
||||
#else
|
||||
#define PK_PLATFORM_SEP '/'
|
||||
#endif
|
||||
|
||||
#if PK_ENABLE_THREAD
|
||||
#define PK_THREAD_LOCAL thread_local
|
||||
#else
|
||||
#define PK_THREAD_LOCAL static
|
||||
#endif
|
||||
|
@ -238,59 +238,47 @@ static int FixedMemoryPool__total_bytes(FixedMemoryPool* self) {
|
||||
return self->BlockCount * self->BlockSize;
|
||||
}
|
||||
|
||||
PK_THREAD_LOCAL FixedMemoryPool PoolExpr;
|
||||
PK_THREAD_LOCAL FixedMemoryPool PoolFrame;
|
||||
PK_THREAD_LOCAL MemoryPool PoolObject;
|
||||
PK_THREAD_LOCAL bool _Pools_initialized = false;
|
||||
static FixedMemoryPool PoolExpr;
|
||||
static FixedMemoryPool PoolFrame;
|
||||
static MemoryPool PoolObject;
|
||||
|
||||
void pk_MemoryPools__initialize(){
|
||||
if(_Pools_initialized) return;
|
||||
FixedMemoryPool__ctor(&PoolExpr, kPoolExprBlockSize, 64);
|
||||
FixedMemoryPool__ctor(&PoolFrame, kPoolFrameBlockSize, 128);
|
||||
MemoryPool__ctor(&PoolObject);
|
||||
_Pools_initialized = true;
|
||||
}
|
||||
|
||||
void pk_MemoryPools__finalize(){
|
||||
if(!_Pools_initialized) return;
|
||||
FixedMemoryPool__dtor(&PoolExpr);
|
||||
FixedMemoryPool__dtor(&PoolFrame);
|
||||
MemoryPool__dtor(&PoolObject);
|
||||
_Pools_initialized = false;
|
||||
}
|
||||
|
||||
void* PoolExpr_alloc() {
|
||||
assert(_Pools_initialized);
|
||||
return FixedMemoryPool__alloc(&PoolExpr);
|
||||
}
|
||||
|
||||
void PoolExpr_dealloc(void* p) {
|
||||
assert(_Pools_initialized);
|
||||
FixedMemoryPool__dealloc(&PoolExpr, p);
|
||||
}
|
||||
|
||||
void* PoolFrame_alloc() {
|
||||
assert(_Pools_initialized);
|
||||
return FixedMemoryPool__alloc(&PoolFrame);
|
||||
}
|
||||
|
||||
void PoolFrame_dealloc(void* p) {
|
||||
assert(_Pools_initialized);
|
||||
FixedMemoryPool__dealloc(&PoolFrame, p);
|
||||
}
|
||||
|
||||
void* PoolObject_alloc() {
|
||||
assert(_Pools_initialized);
|
||||
return MemoryPool__alloc(&PoolObject);
|
||||
}
|
||||
|
||||
void PoolObject_dealloc(void* p) {
|
||||
assert(_Pools_initialized);
|
||||
MemoryPool__dealloc(&PoolObject, p);
|
||||
}
|
||||
|
||||
void PoolObject_shrink_to_fit() {
|
||||
assert(_Pools_initialized);
|
||||
MemoryPool__shrink_to_fit(&PoolObject);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user