Skip to content

Commit

Permalink
Add swig.WaitForBlock(dec, sbn, err)
Browse files Browse the repository at this point in the history
Make it wait for any block to be available and return its status.

FTR, potential error codes from compute() include:

* swig.Error_NONE -> source block (sbn) is ready
* swig.Error_EXITING -> underlying decoder has been deleted
* swig.Error_NEED_DATA -> source block (sbn) has reached end-of-input
  (as indicated by the caller) but still cannot be decoded.

Since we do not inject end-of-input, we will not get and do not have to
process NEED_DATA.
  • Loading branch information
Eugene Kim committed Dec 18, 2018
1 parent 1ef7550 commit d27f86f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/impl/libraptorq/swig/swig.swigcxx
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ public:
%inline %{

typedef RFC6330__v1::Impl::Encoder<unsigned char *, unsigned char *> BytesEncoder;
typedef RFC6330__v1::Impl::Decoder<unsigned char *, unsigned char *> BytesDecoder;

BytesEncoder *InitBytesEncoder(
unsigned char *SLICEBEGIN, unsigned char *SLICEEND,
Expand All @@ -1110,4 +1111,10 @@ BytesEncoder *InitBytesEncoder(
return enc;
}

void WaitForBlock(BytesDecoder *dec, uint8_t &sbn, RFC6330__v1::Error &err) {
auto result = dec->compute(RFC6330__v1::Compute::PARTIAL_ANY).get();
err = result.first;
sbn = result.second;
}

%}

0 comments on commit d27f86f

Please sign in to comment.