MCPcopy Index your code
hub / github.com/apache/tvm / SocketChannel

Class SocketChannel

jvm/core/src/main/java/org/apache/tvm/rpc/SocketChannel.java:28–69  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26import org.apache.tvm.TVMValueBytes;
27
28public class SocketChannel {
29 private final Socket socket;
30
31 SocketChannel(Socket sock) {
32 socket = sock;
33 }
34
35 private Function fsend = Function.convertFunc(new Function.Callback() {
36 @Override
37 public Object invoke(TVMValue... args) {
38 byte[] data = args[0].asBytes();
39 try {
40 socket.getOutputStream().write(data);
41 } catch (IOException e) {
42 e.printStackTrace();
43 return -1;
44 }
45 return data.length;
46 }
47 });
48
49 private Function frecv = Function.convertFunc(new Function.Callback() {
50 @Override
51 public Object invoke(TVMValue... args) {
52 long size = args[0].asLong();
53 try {
54 return new TVMValueBytes(Utils.recvAll(socket.getInputStream(), (int) size));
55 } catch (IOException e) {
56 e.printStackTrace();
57 return -1;
58 }
59 }
60 });
61
62 public Function getFsend() {
63 return fsend;
64 }
65
66 public Function getFrecv() {
67 return frecv;
68 }
69}

Callers

nothing calls this directly

Calls 1

convertFuncMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…