We didnât change the algorithm; however what did happen is that the GC is now pluggable. On WebAssembly thereâs a different GC (single threaded, reference counted with cycle support)
Anyhow, I wonder what you are up to in relation to the RAII - Concept of C++ MemoryManagement? What do you think about its model? Love to hear your opinion
We do have some limited RAII support when using records on Island. Essentially:
constructor;
// gets called when defining a type of that type but not explicitly initializing it.
constructor Copy(var aValue: StructType);
// gets called when create a value from another value (should copy but "self" will be uninitialized).
class operator Assign(var aDest: StructType; var aSource: StructType);
// gets called for a = b assignments; both aDest and aSource are initialized; if @aDest <> @aSource then aDest should be cleaned up.
finalizer;
// gets called when the scope for that type ends.
so when using records, do I have something to do, for instance, using some raii-operators explicitly or is it autom cleaned up after each function, so when a record keeps unmanaged resources, because C++ uses mangement-classes for this, to wrap the unmanaged-resources and calling the destructor of the class when the lifetime of the function ends, so the handle(ptr) ends aswell, as without being wrapped in a class, hopefully u understand me ^^
Because this ofc makes only sense by unmanaged-resources as valuetypes are destroyed after they go out of scope, so I thought we should use records to encapsulate the pointerstuff and then let the stack do both, remove the record from stack and clean up unmang. resources
Actually, I just have been really interessted in proper memory-management, so it was just a general issue for me, no concrete thing.
And what do you thing about this, is it not a good practice or yes or what?
TMutex = public record
someStuff: TStuff;
//and so on...
end;
TLock = public record
private
mutexProp: ^TMutex;
public
constructor(pm: ^TMutex);
begin
mutexProp := pm;
Mutex_Lock(mutexProp);
end;
finalizer();
begin
Mutex_Unlock(mutexProp);
end;
end;
So, when using in a function, u now use the TLock-record instead of just the functions from âMutex_Lock(pm) - Mutex_Unlock(pm)â because the mutex could be always locked, in case of some error occurs before unlocking the mutex.