Get rid of fiber for finalizers.
Instead, finalizers just get access to the foreign object's raw bytes. This is deliberately limiting, since it discourages the user from interacting with the VM in the middle of a GC.
This commit is contained in:
@@ -69,11 +69,16 @@ static void pointToString(WrenVM* vm)
|
||||
|
||||
static void resourceAllocate(WrenVM* vm)
|
||||
{
|
||||
wrenAllocateForeign(vm, 0);
|
||||
int* value = (int*)wrenAllocateForeign(vm, sizeof(int));
|
||||
*value = 123;
|
||||
}
|
||||
|
||||
static void resourceFinalize(WrenVM* vm)
|
||||
static void resourceFinalize(void* data)
|
||||
{
|
||||
// Make sure we get the right data back.
|
||||
int* value = (int*)data;
|
||||
if (*value != 123) exit(1);
|
||||
|
||||
finalized++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user