Skip to content

Commit

Permalink
add doc for CallbackChannel
Browse files Browse the repository at this point in the history
  • Loading branch information
yzhliu committed Oct 23, 2019
1 parent cedabad commit 097ee8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 5 additions & 1 deletion src/runtime/rpc/rpc_event_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ namespace runtime {
PackedFunc CreateEventDrivenServer(PackedFunc fsend,
std::string name,
std::string remote_key) {
std::unique_ptr<CallbackChannel> ch(new CallbackChannel(fsend));
static PackedFunc frecv([](TVMArgs args, TVMRetValue* rv) {
LOG(FATAL) << "Do not allow explicit receive";
return 0;
});
std::unique_ptr<CallbackChannel> ch(new CallbackChannel(fsend, frecv));
std::shared_ptr<RPCSession> sess =
RPCSession::Create(std::move(ch), name, remote_key);
return PackedFunc([sess](TVMArgs args, TVMRetValue* rv) {
Expand Down
12 changes: 4 additions & 8 deletions src/runtime/rpc/rpc_session.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,19 +253,15 @@ class RPCSession {
std::string remote_key_;
};

/*!
* \brief RPC channel which callback
* frontend (Python/Java/etc.)'s send & recv function
*/
class CallbackChannel final : public RPCChannel {
public:
explicit CallbackChannel(PackedFunc fsend, PackedFunc frecv)
: fsend_(std::move(fsend)), frecv_(std::move(frecv)) {}

explicit CallbackChannel(PackedFunc fsend)
: fsend_(std::move(fsend)) {
PackedFunc frecv([](TVMArgs args, TVMRetValue* rv) {
LOG(FATAL) << "Do not allow explicit receive";
return 0;
});
frecv_ = frecv;
}
~CallbackChannel() {}
/*!
* \brief Send data over to the channel.
Expand Down

0 comments on commit 097ee8f

Please sign in to comment.