Coroutines using GetCompressedStack?

  • Thread starter Thread starter Ken
  • Start date Start date
K

Ken

Does anyone know if it's possible to use Thread.GetCompressedStack and Thread.SetCompressedStack as the basis for a coroutine
library? There doesn't seem to be a lot of documentation on these methods, although I seem to remember reading somewhere that they
are intended for internal .Net use and aren't really supposed to be used by applications.

Thanks,
Ken
 
Ken said:
Does anyone know if it's possible to use Thread.GetCompressedStack and
Thread.SetCompressedStack as the basis for a coroutine library? There
doesn't seem to be a lot of documentation on these methods, although I
seem to remember reading somewhere that they are intended for internal
.Net use and aren't really supposed to be used by applications.

It may be possible, but the framework has a security attribute on it that I
was never able to bypass. I'm no master of security but it certainly isn't
terribly happy about it, meaning such a library would be *very* security
fragile. If it is possible it may well not be a feasiable tool to use
anywhere.

*HOWEVER*, I think it could be possible to achieve psuedo-coroutines(look
and act liek them without full stack swapping) using techniques like those
used in C# for its iterators and anonymous methods. That is, writing
acompiler that generates state machines and uses non-stack based locals. I'm
just not sure how well that will work in the real world.
 
Ken,

The documentation for these in .NET 2.0 no longer states that they are
for internal use only. As a matter of fact, I believe because of the work
that was done to host the runtime in SQL server, support for fibers as
managed threads was added in.

Now, whether or not the Thread class uses fibers, I think that in
general, you would have to host the runtime to set that particular setting.
I'm not sure of the specifics, but I would poke around in the beta, as I
know significant changes have been made to the Thread object.

Hope this helps.
 
Back
Top