Too bad the callback isn't single-shot... This is how I envision the Pike API to work:
{ object b = Browse("_http._tcp"); res1 = b->get_results(); // get all results so far res2 = b->get_results(); // get all results so far b->stop(); // terminate async lookup res3 = b->get_results(); // all results at the time of stop() }
Now, if I don't call stop() the results array should keep updating for as long as b is valid. Handling destruct(b) should be easy, but the problem is if b goes out of scope and loses a ref; since we've added a ref internally we won't detect that case and the lookup will continue forever.
I'm thinking I'm better off not adding the ref to begin with. Then my destroy() method can do whatever stop() does to cancel the lookup, and I'll pray that the callback isn't invoked with an old object any more (which shouldn't happen unless there are bugs in the library).