diff --git a/Parallel/IpcParallel/SlaveTask.vb b/Parallel/IpcParallel/SlaveTask.vb index 0fd3ce0..a17f5b5 100644 --- a/Parallel/IpcParallel/SlaveTask.vb +++ b/Parallel/IpcParallel/SlaveTask.vb @@ -20,6 +20,10 @@ Public Class SlaveTask Me.builder = cli Me.processor = processor Me.debugPort = debugPort + + For Each [handle] In EmitHandler.PopulatePrimitiveHandles + toBuffers(handle.target) = handle.emit + Next End Sub Public Function Emit(Of T)(streamAs As Func(Of T, Stream)) As SlaveTask diff --git a/Parallel/IpcParallel/Stream/EmitHandler.vb b/Parallel/IpcParallel/Stream/EmitHandler.vb new file mode 100644 index 0000000..0a929aa --- /dev/null +++ b/Parallel/IpcParallel/Stream/EmitHandler.vb @@ -0,0 +1,15 @@ +Imports System.IO +Imports System.Text + +Module EmitHandler + + Public Iterator Function PopulatePrimitiveHandles() As IEnumerable(Of (target As Type, emit As Func(Of Object, Stream))) + Yield (GetType(Integer), Function(i) New MemoryStream(BitConverter.GetBytes(DirectCast(i, Integer)))) + Yield (GetType(Long), Function(l) New MemoryStream(BitConverter.GetBytes(DirectCast(l, Long)))) + Yield (GetType(Single), Function(f) New MemoryStream(BitConverter.GetBytes(DirectCast(f, Single)))) + Yield (GetType(Double), Function(d) New MemoryStream(BitConverter.GetBytes(DirectCast(d, Double)))) + Yield (GetType(Short), Function(s) New MemoryStream(BitConverter.GetBytes(DirectCast(s, Short)))) + Yield (GetType(Boolean), Function(b) New MemoryStream(New Byte() {If(DirectCast(b, Boolean), 1, 0)})) + Yield (GetType(String), Function(s) New MemoryStream(Encoding.UTF8.GetBytes(DirectCast(s, String)))) + End Function +End Module diff --git a/Parallel/Parallel.vbproj b/Parallel/Parallel.vbproj index 8cc7b24..4d474c3 100644 --- a/Parallel/Parallel.vbproj +++ b/Parallel/Parallel.vbproj @@ -124,10 +124,11 @@ - + + - +