Skip to content

Commit

Permalink
Merge pull request commaai#10 from commaai/msgq
Browse files Browse the repository at this point in the history
Enable MSGQ
  • Loading branch information
pd0wm authored Nov 8, 2019
2 parents fbc4a4c + 4873449 commit 4a61269
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __getitem__(self, s):
def update(self, timeout=1000):
msgs = []
for sock in self.poller.poll(timeout):
msgs.append(recv_one(sock))
msgs.append(recv_one_or_none(sock))
self.update_msgs(sec_since_boot(), msgs)

def update_msgs(self, cur_time, msgs):
Expand Down
29 changes: 25 additions & 4 deletions messaging/messaging.cc
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
#include "messaging.hpp"
#include "impl_zmq.hpp"
#include "impl_msgq.hpp"

Context * Context::create(){
Context * c = new ZMQContext();
Context * c;
if (std::getenv("ZMQ")){
c = new ZMQContext();
} else {
c = new MSGQContext();
}
return c;
}

SubSocket * SubSocket::create(){
SubSocket * s = new ZMQSubSocket();
SubSocket * s;
if (std::getenv("ZMQ")){
s = new ZMQSubSocket();
} else {
s = new MSGQSubSocket();
}
return s;
}

Expand All @@ -26,7 +37,12 @@ SubSocket * SubSocket::create(Context * context, std::string endpoint, std::stri
}

PubSocket * PubSocket::create(){
PubSocket * s = new ZMQPubSocket();
PubSocket * s;
if (std::getenv("ZMQ")){
s = new ZMQPubSocket();
} else {
s = new MSGQPubSocket();
}
return s;
}

Expand All @@ -37,7 +53,12 @@ PubSocket * PubSocket::create(Context * context, std::string endpoint){
}

Poller * Poller::create(){
Poller * p = new ZMQPoller();
Poller * p;
if (std::getenv("ZMQ")){
p = new ZMQPoller();
} else {
p = new MSGQPoller();
}
return p;
}

Expand Down

0 comments on commit 4a61269

Please sign in to comment.