forked from huajsj/tvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rpc] use callback func to do send & recv (apache#4147)
* [rpc] use callback func to do send & recv. don't get fd from sock as it is deprecated in java * fix java build * fix min/max macro define in windows * keep the old rpc setup for py * add doc for CallbackChannel
- Loading branch information
Showing
16 changed files
with
165 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package ml.dmlc.tvm.rpc; | ||
|
||
import ml.dmlc.tvm.Function; | ||
import ml.dmlc.tvm.TVMValue; | ||
import ml.dmlc.tvm.TVMValueBytes; | ||
|
||
import java.io.IOException; | ||
import java.net.Socket; | ||
|
||
public class SocketChannel { | ||
private final Socket socket; | ||
|
||
SocketChannel(Socket sock) { | ||
socket = sock; | ||
} | ||
|
||
private Function fsend = Function.convertFunc(new Function.Callback() { | ||
@Override public Object invoke(TVMValue... args) { | ||
byte[] data = args[0].asBytes(); | ||
try { | ||
socket.getOutputStream().write(data); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return -1; | ||
} | ||
return data.length; | ||
} | ||
}); | ||
|
||
private Function frecv = Function.convertFunc(new Function.Callback() { | ||
@Override public Object invoke(TVMValue... args) { | ||
long size = args[0].asLong(); | ||
try { | ||
return new TVMValueBytes(Utils.recvAll(socket.getInputStream(), (int) size)); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
return -1; | ||
} | ||
} | ||
}); | ||
|
||
public Function getFsend() { | ||
return fsend; | ||
} | ||
|
||
public Function getFrecv() { | ||
return frecv; | ||
} | ||
} |
32 changes: 0 additions & 32 deletions
32
jvm/core/src/main/java/ml/dmlc/tvm/rpc/SocketFileDescriptorGetter.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.