add debug diagnose output

master
この中二病に爆焔を! 5 years ago
parent af1c46c92b
commit c6b0576f89

@ -63,6 +63,7 @@ Public Class IPCSocket : Implements ITaskDriver
<Protocol(Protocols.GetTask)>
Public Function GetTask(request As RequestStream, remoteAddress As System.Net.IPEndPoint) As BufferPipe
Call Console.WriteLine($"[{GetHashCode.ToHexString}] get parallel task entry.")
Return New DataPipe(Encoding.UTF8.GetBytes(target.GetJson))
End Function
@ -75,6 +76,12 @@ Public Class IPCSocket : Implements ITaskDriver
Return pipe
End Function
<Protocol(Protocols.PostStart)>
Public Function PostStart(request As RequestStream, remoteAddress As System.Net.IPEndPoint) As BufferPipe
Call Console.WriteLine($"[{GetHashCode.ToHexString}] started!")
Return New DataPipe(Encoding.UTF8.GetBytes("OK!"))
End Function
<Protocol(Protocols.GetArgumentNumber)>
Public Function GetArgumentNumber(request As RequestStream, remoteAddress As System.Net.IPEndPoint) As BufferPipe
Return New DataPipe(BitConverter.GetBytes(nargs))

@ -2,5 +2,6 @@
GetTask
GetArgumentNumber
GetArgumentByIndex
PostStart
PostResult
End Enum

@ -31,7 +31,9 @@ Public Class SlaveTask
Return Me
End Function
Private Function handlePOST(buf As Stream, type As Type) As Object
Private Function handlePOST(buf As Stream, type As Type, debugCode As Integer) As Object
Call Console.WriteLine($"[{debugCode.ToHexString}] task finished!")
If fromBuffer.ContainsKey(type) Then
Return fromBuffer(type)(buf)
Else
@ -39,9 +41,11 @@ Public Class SlaveTask
End If
End Function
Private Function handleGET(param As Object) As ObjectStream
Private Function handleGET(param As Object, i As Integer, debugCode As Integer) As ObjectStream
Dim type As Type = param.GetType
Call Console.WriteLine($"[{debugCode.ToHexString}] get argument[{i + 1}]...")
If toBuffers.ContainsKey(type) Then
Return New ObjectStream(New TypeInfo(type, fullpath:=True), StreamMethods.Emit, toBuffers(type)(param))
Else
@ -55,12 +59,16 @@ Public Class SlaveTask
Public Function RunTask(entry As [Delegate], ParamArray parameters As Object()) As Object
Dim target As New IDelegate(entry)
Dim result As Object = Nothing
Dim host As New IPCSocket(target, debugPort) With {
.handlePOSTResult = Sub(buf) result = handlePOST(buf, entry.Method.ReturnType),
Dim host As IPCSocket = Nothing
host = New IPCSocket(target, debugPort) With {
.handlePOSTResult = Sub(buf) result = handlePOST(buf, entry.Method.ReturnType, host.GetHashCode),
.nargs = parameters.Length,
.handleGetArgument = Function(i) handleGET(parameters(i))
.handleGetArgument = Function(i) handleGET(parameters(i), i, host.GetHashCode)
}
Call Console.WriteLine($"[{host.GetHashCode.ToHexString}] port:{host.HostPort}")
Call New Thread(AddressOf host.Run).Start()
Call Thread.Sleep(100)

@ -35,6 +35,8 @@ Public Class TaskBuilder : Implements ITaskDriver
End If
Next
' send debug message
Call New TcpRequest(masterPort).SendMessage(New RequestStream(IPCSocket.Protocol, Protocols.PostStart))
Call PostFinished(api.Invoke(Nothing, args.ToArray))
Return 0

Loading…
Cancel
Save