From 4593da7ccdb222b406e22a80762f13f7622479ea Mon Sep 17 00:00:00 2001 From: xieguigang Date: Fri, 2 Apr 2021 16:44:33 +0800 Subject: [PATCH] bugs fixed of passing parameter values --- Parallel/IpcParallel/IDelegate.vb | 4 ++ Parallel/IpcParallel/IPCSocket.vb | 91 +++++++++++++++-------------- Parallel/IpcParallel/SlaveTask.vb | 10 +++- Parallel/IpcParallel/TaskBuilder.vb | 1 + 4 files changed, 58 insertions(+), 48 deletions(-) diff --git a/Parallel/IpcParallel/IDelegate.vb b/Parallel/IpcParallel/IDelegate.vb index e4cca78..7ef5670 100644 --- a/Parallel/IpcParallel/IDelegate.vb +++ b/Parallel/IpcParallel/IDelegate.vb @@ -85,6 +85,10 @@ Public Class IDelegate Call Me.New(target.Method) End Sub + ''' + ''' is static or instance method? + ''' + ''' Public Function GetMethodTarget() As Object Dim type As Type = provideType() diff --git a/Parallel/IpcParallel/IPCSocket.vb b/Parallel/IpcParallel/IPCSocket.vb index f639ea1..fd95ffe 100644 --- a/Parallel/IpcParallel/IPCSocket.vb +++ b/Parallel/IpcParallel/IPCSocket.vb @@ -1,49 +1,49 @@ #Region "Microsoft.VisualBasic::596f11e06500e4ccde1801ae45c85a3e, Parallel\IpcParallel\IPCSocket.vb" - ' Author: - ' - ' asuka (amethyst.asuka@gcmodeller.org) - ' xie (genetics@smrucc.org) - ' xieguigang (xie.guigang@live.com) - ' - ' Copyright (c) 2018 GPL3 Licensed - ' - ' - ' GNU GENERAL PUBLIC LICENSE (GPL3) - ' - ' - ' This program is free software: you can redistribute it and/or modify - ' it under the terms of the GNU General Public License as published by - ' the Free Software Foundation, either version 3 of the License, or - ' (at your option) any later version. - ' - ' This program is distributed in the hope that it will be useful, - ' but WITHOUT ANY WARRANTY; without even the implied warranty of - ' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ' GNU General Public License for more details. - ' - ' You should have received a copy of the GNU General Public License - ' along with this program. If not, see . - - - - ' /********************************************************************************/ - - ' Summaries: - - ' Class IPCSocket - ' - ' Properties: handleError, handleGetArgument, handlePOSTResult, host, HostPort - ' nargs, Protocol - ' - ' Constructor: (+1 Overloads) Sub New - ' - ' Function: GetArgumentByIndex, GetArgumentNumber, GetFirstAvailablePort, GetTask, PostError - ' PostResult, PostStart, Run - ' - ' Sub: [Stop] - ' - ' /********************************************************************************/ +' Author: +' +' asuka (amethyst.asuka@gcmodeller.org) +' xie (genetics@smrucc.org) +' xieguigang (xie.guigang@live.com) +' +' Copyright (c) 2018 GPL3 Licensed +' +' +' GNU GENERAL PUBLIC LICENSE (GPL3) +' +' +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY; without even the implied warranty of +' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +' GNU General Public License for more details. +' +' You should have received a copy of the GNU General Public License +' along with this program. If not, see . + + + +' /********************************************************************************/ + +' Summaries: + +' Class IPCSocket +' +' Properties: handleError, handleGetArgument, handlePOSTResult, host, HostPort +' nargs, Protocol +' +' Constructor: (+1 Overloads) Sub New +' +' Function: GetArgumentByIndex, GetArgumentNumber, GetFirstAvailablePort, GetTask, PostError +' PostResult, PostStart, Run +' +' Sub: [Stop] +' +' /********************************************************************************/ #End Region @@ -52,6 +52,7 @@ Imports System.Text Imports Microsoft.VisualBasic.ComponentModel #If netcore5 = 1 Then Imports Microsoft.VisualBasic.ComponentModel.Collection +Imports Microsoft.VisualBasic.Linq #End If Imports Microsoft.VisualBasic.Net.Protocols.Reflection Imports Microsoft.VisualBasic.Net.Tcp @@ -155,7 +156,7 @@ Public Class IPCSocket : Implements ITaskDriver Public Function PostError(request As RequestStream, remoteAddress As System.Net.IPEndPoint) As BufferPipe Using ms As New MemoryStream(request.ChunkBuffer) - Call _handleError(host.streamBuf.handleCreate(ms, GetType(IPCError), StreamMethods.Auto)) + Call DirectCast(SlaveTask.GetValueFromStream(ms, GetType(IPCError), host.streamBuf), IPCError).DoCall(_handleError) End Using Return New DataPipe(Encoding.ASCII.GetBytes("OK!")) diff --git a/Parallel/IpcParallel/SlaveTask.vb b/Parallel/IpcParallel/SlaveTask.vb index 5b237a9..1298ded 100644 --- a/Parallel/IpcParallel/SlaveTask.vb +++ b/Parallel/IpcParallel/SlaveTask.vb @@ -65,6 +65,7 @@ Public Class SlaveTask Friend ReadOnly streamBuf As New StreamEmit + Sub New(processor As InteropService, cli As ISlaveTask, Optional debugPort As Integer? = Nothing, Optional ignoreError As Boolean = False) @@ -93,15 +94,18 @@ Public Class SlaveTask ''' ''' Private Function handlePOST(buf As Stream, type As Type, debugCode As Integer) As Object + Call Console.WriteLine($"[{debugCode.ToHexString}] task finished!") + Return GetValueFromStream(buf, type, streamBuf) + End Function + + Friend Shared Function GetValueFromStream(buf As Stream, type As Type, streamBuf As StreamEmit) As Object Dim obj As New ObjectStream(buf) Dim socket As SocketRef = SocketRef.GetSocket(obj) obj = socket.Open - Call Console.WriteLine($"[{debugCode.ToHexString}] task finished!") - Using file As MemoryStream = obj.openMemoryBuffer - Return streamBuf.handleCreate(buf, type, obj.method) + Return streamBuf.handleCreate(file, type, obj.method) End Using End Function diff --git a/Parallel/IpcParallel/TaskBuilder.vb b/Parallel/IpcParallel/TaskBuilder.vb index cd19bc0..a555e6f 100644 --- a/Parallel/IpcParallel/TaskBuilder.vb +++ b/Parallel/IpcParallel/TaskBuilder.vb @@ -63,6 +63,7 @@ Public Class TaskBuilder : Implements ITaskDriver ReadOnly masterPort As Integer ReadOnly emit As New StreamEmit + Sub New(port As Integer) masterPort = port End Sub