Re: My thoughts on C# and gaming.
Miguel de Icaza <[email protected]>
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <[email protected]> |
Hello,
> So, in my question, I'm assuming that the implementation of
> DisposeThePool() walks all other pools (roots), looking for references
> into the pool getting disposed. I imagine that the stack counts as a
> root/pool in this case, just like any other garbage collection case.
> Given that there is weak pointer support in the runtime in general,
> implementing this safety should not be all that hard (compared to the
> other problems you have to solve).
You could use weak pointers, but that does not guarantee type safety, it
merely allows you to write this code:
Foo foo = new Foo ();
WeakReference f = new WeakReference (foo);
DisposePools ();
if (f.IsValid){
foo = f.Target;
foo.Value = n;
}
The other option is to have DisposePools refuse to dispose the pool if
it can determine that there are references that point into the pool (or
block, but that is not much of a solution, as that is trivial to
deadlock).
If you are happy with the above scenario, more power to you. My point
was that the introduction of "Release Pools" breaks the semantics
expected on the safe execution environment and shifts the burden from
the compiler/runtime to the programmer. There are plenty of cases
where this is acceptable, you do not even need to go too far to find
those.
Miguel
_______________________________________________
Sweng-Gamedev mailing list
[email protected]
http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com