[Mono-list] Trying to port parallel tasks back to .net 3.5

josh_k df32423634sdf at gmail.com
Wed May 1 19:35:18 UTC 2013


Hello.

I'm working with Unity3D game engine, which uses older version of Mono, so
I'm stuck with libraries equivalent to .net 3.5. I'd like to be able to use
parallel loops and tasks, so I've grabbed sources for System.Threading.Tasks
and System.Collections.Concurrent from newer Mono version and tried to make
them at least compile. 

Most of the problems I'm having are with SpinWait class. It relies on
Thread.Yield() method, which does not exist in 3.5, and I'm not really sure
how to get same behavior without it. Its description says "This method is
equivalent to using platform invoke to call the native Win32 SwitchToThread
function. ", but in Unity I can't call native functions either.

Another problem is in Watch class, that uses DateTime.GetTimeMonotonic(),
which isn't really a part of DateTime class in any .net version. Seems like
it's basically used as a Timer, and could be replaced with it.

Last issue I've run into is in ManualResetEventSlim, that stores
ManualResetEvent and calls Dispose on it. This method is not available in
3.5 version of ManualResetEvent, but I'm pretty sure Close() does the same
thing. 

For now I've replaced Thread.Yield() with Thread.Sleep(0),
DateTime.GetTimeMonotonic() with DateTime.Now.Ticks, and Dispose() with
Close(). It seems to at least somewhat work, but I won't be surprised if I
actually horribly ruined everything.

I'd like some advice on those points, because I'm really not confident in my
ability to implement this correctly.



--
View this message in context: http://mono.1490590.n4.nabble.com/Trying-to-port-parallel-tasks-back-to-net-3-5-tp4659571.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list