fix of the para,meters

master
この中二病に爆焔を! 2 years ago
parent f16c85a763
commit 31d729cc5e

@ -1,7 +1,7 @@
Imports batch
Imports Microsoft.VisualBasic.Math
Imports Microsoft.VisualBasic.Math.Correlations
Imports Parallel
Imports Microsoft.VisualBasic.MIME.application.json
Imports Parallel.IpcStream
Imports rnd = Microsoft.VisualBasic.Math.RandomExtensions
@ -30,10 +30,13 @@ Module clr_parallelTask_demo
Call Console.WriteLine("memory data create job done!")
Call Console.WriteLine("create parallrl task...")
Dim snowFall As SlaveTask = Host.CreateSlave(verbose:=True)
Dim args As New Argument(4)
Dim memory_symbol1 As SocketRef = SocketRef.WriteBuffer(pool)
Dim result = Host.ParallelFor(Of vectorData, Double())(args, New Func(Of vectorData, vectorData(), Double())(AddressOf compute_function), pool, memory_symbol1)
For Each item In result
Call Console.WriteLine(item.GetJson)
Next
End Sub
End Module

@ -8,6 +8,13 @@ Public Class Argument
Public Property ignoreError As Boolean = False
Public Property n_threads As Integer = 32
Sub New()
End Sub
Sub New(n_threads As Integer)
Me.n_threads = n_threads
End Sub
Public Overrides Function ToString() As String
Return Me.GetJson
End Function

@ -55,9 +55,12 @@ Public Module Host
End Function
<Extension>
Public Function ParallelFor(Of T)(par As Argument, task As [Delegate], [loop] As SocketRef(), ParamArray args As SocketRef()) As IEnumerable(Of T)
Public Function ParallelFor(Of I, T)(par As Argument, task As [Delegate], [loop] As I(), ParamArray args As SocketRef()) As IEnumerable(Of T)
Dim foreach As New ParallelFor(Of T)(par)
Dim run = batch.ParallelFor(Of T).CreateFunction(par, task, [loop], args)
Dim loopVal As SocketRef() = [loop] _
.Select(Function(obj) SocketRef.WriteBuffer(obj)) _
.ToArray
Dim run = batch.ParallelFor(Of T).CreateFunction(par, task, loopVal, args)
Return foreach.GetResult(run)
End Function

Loading…
Cancel
Save