SodiumFRP / sodium

Sodium - Functional Reactive Programming (FRP) Library for multiple languages
http://sodium.nz/
Other
848 stars 138 forks source link

added Sodium.NetStandard1_1 #119

Closed Confuset closed 6 years ago

Confuset commented 6 years ago

Added new Project for NetStandard1_1. All sourcecode files are linked into this project from the original Sodium project. The lowest possible .Net Standard was 1.1 since Sodium requires System.Collections.Concurrent which is available only since 1.1. I also had to remove all usages of Thread in StreamListenerManager.cs as this would only be fully available since .Net Standard 2.0 and reimplementation with Tasks is pretty straight forward. I moved the lambdas into named functions because when debugging the name of the method will be available to the debugger. This was done to get close to naming the Thread, like it was before.

jam40jeff commented 6 years ago

Fixes #114

jam40jeff commented 6 years ago

Looks good, although if we are going to use Tasks, would it make sense to use BufferBlock<T> rather than BlockingCollection<T>? The upside would be that we would be able to release the thread pool thread while waiting for the next stream to clean up. The downside would be that we would be taking a dependency on a new NuGet package (System.Threading.Tasks.Dataflow), although I'm not sure that's really a bad thing since it's a pretty useful official Microsoft package.

Confuset commented 6 years ago

hm. I can't really say anything about BlockingCollection or BufferBlock as I have never used it. But freeing up some ressources might make sense.

Another option could be to implement something on our own that does what is needed here:

what you think?

Confuset commented 6 years ago

I thougt about this a bit more. I think we can simplify this. Since we only have one consumer, we could simply use an AsyncAutoResetEvent and WaitAsync on this until it gets signaled from a different thread. If so do some cleanup and WaitAsync again.

This way we could pretty much stick to the current implementation, do not need to depend on the additional nuget package and wrap that BlockingCollection. We can use this implementation from Stephan Toub himself… https://blogs.msdn.microsoft.com/pfxteam/2012/02/11/building-async-coordination-primitives-part-2-asyncautoresetevent/

Confuset commented 6 years ago

It turned out, that we don't really need the BlockingCollection and it can be replaced by a simple Queue and some sync logic around it.

jam40jeff commented 6 years ago

Looks great, thank you!