merlimat commented on a change in pull request #2011: Cpp client: python client 
wrapper for reader hasMessageAvaliable
URL: https://github.com/apache/incubator-pulsar/pull/2011#discussion_r197198935
 
 

 ##########
 File path: pulsar-client-cpp/lib/c/c_Reader.cc
 ##########
 @@ -52,3 +52,11 @@ void pulsar_reader_close_async(pulsar_reader_t *reader, 
pulsar_result_callback c
 }
 
 void pulsar_reader_free(pulsar_reader_t *reader) { delete reader; }
+
+pulsar_result pulsar_reader_has_message_available(pulsar_reader_t *reader, int 
*available) {
+    bool ava = (*available != 0);
+    bool &para = ava;
+    pulsar_result result = 
(pulsar_result)reader->reader.hasMessageAvailable(para);
+    *available = para;
+    return result;
 
 Review comment:
   `available` is a return only parameter, we shouldn't use its value. Also, 
there's no need to have a `bool&`  typed argument, passing a `bool` to the 
method that takes `bool&` will automatically pass a reference to that variable.
   
   The function could be as in : 
   ```cpp
   bool isAvailable;
   pulsar_result result = (pulsar_result) 
reader->reader.hasMessageAvailable(isAvailable);
   *available = isAvailable;
   return result;
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to