@@ -90,6 +90,9 @@ resolver_impl *resolver_impl::create_resolver(
9090
9191std::vector<stream_info_impl> resolver_impl::resolve_oneshot (
9292 const std::string &query, int minimum, double timeout, double minimum_time) {
93+ if (status == resolver_status::running_continuous)
94+ throw std::logic_error (" resolve_oneshot called during continuous operation" );
95+
9396 check_query (query);
9497 // reset the IO service & set up the query parameters
9598 io_->restart ();
@@ -113,6 +116,8 @@ std::vector<stream_info_impl> resolver_impl::resolve_oneshot(
113116 // start the first wave of resolve packets
114117 next_resolve_wave ();
115118
119+ status = resolver_status::started_oneshot;
120+
116121 // run the IO operations until finished
117122 if (!cancelled_) {
118123 io_->run ();
@@ -125,6 +130,9 @@ std::vector<stream_info_impl> resolver_impl::resolve_oneshot(
125130}
126131
127132void resolver_impl::resolve_continuous (const std::string &query, double forget_after) {
133+ if (status == resolver_status::running_continuous)
134+ throw std::logic_error (" resolve_continuous called during another continuous operation" );
135+
128136 check_query (query);
129137 // reset the IO service & set up the query parameters
130138 io_->restart ();
@@ -139,9 +147,13 @@ void resolver_impl::resolve_continuous(const std::string &query, double forget_a
139147 next_resolve_wave ();
140148 // spawn a thread that runs the IO operations
141149 background_io_ = std::make_shared<std::thread>([shared_io = io_]() { shared_io->run (); });
150+ status = resolver_status::running_continuous;
142151}
143152
144153std::vector<stream_info_impl> resolver_impl::results (uint32_t max_results) {
154+ if (status == resolver_status::empty)
155+ throw std::logic_error (" results() called before starting a resolve operation" );
156+
145157 std::vector<stream_info_impl> output;
146158 std::lock_guard<std::mutex> lock (results_mut_);
147159 double expired_before = lsl_clock () - forget_after_;
0 commit comments