Skip to content

Commit

Permalink
Correct mapping between node pairs and rings
Browse files Browse the repository at this point in the history
  • Loading branch information
rigtorp committed Nov 12, 2010
1 parent 31250be commit 9798fd4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ TARGETS = local_lat remote_lat local_thr remote_thr

all: $(TARGETS)

$(TARGETS): include/nmq.hpp

clean:
rm -f *~
rm -f $(TARGETS)
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
* Monitor message throughput
* Ping nodes to check if they are running
* Message framing, ie send message length
* Unit tests
17 changes: 13 additions & 4 deletions include/nmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,22 @@ class context_t {
return 1U << i;
}

ring* get_ring(unsigned int from, unsigned int to) {
// TODO set errno and return error condition
assert(p_ != NULL);
// Node pair to ring
unsigned int np2r(unsigned int from, unsigned int to) {
assert(from != to);
assert(from < header_->nodes);
assert(to < header_->nodes);
return &ring_[from*(to - 1) + 1];
if (from > to) {
return to * (header_->nodes - 1) + from - 1;
} else {
return to * (header_->nodes - 1) + from;
}
}

ring* get_ring(unsigned int from, unsigned int to) {
// TODO set errno and return error condition
assert(p_ != NULL);
return &ring_[np2r(from, to)];
}

bool send(ring *ring, const void *msg, size_t size) {
Expand Down

0 comments on commit 9798fd4

Please sign in to comment.