Skip to content

Commit

Permalink
Adding destruction flag to stop queries as soon as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
OhadMeir committed Dec 26, 2023
1 parent a128169 commit cd0b14e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/core/options-watcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ namespace librealsense {

options_watcher::options_watcher( std::chrono::milliseconds update_interval )
: _update_interval( update_interval )
, _destructing( false )
{
}

options_watcher::~options_watcher()
{
_destructing = true;
try
{
{
std::lock_guard< std::mutex > lock( _mutex );
_options.clear();
}
_options.clear();
stop();
}
catch( ... )
Expand Down Expand Up @@ -71,7 +70,7 @@ bool options_watcher::should_start() const

bool options_watcher::should_stop() const
{
return _on_values_changed.size() == 0 || _options.size() == 0;
return _on_values_changed.size() == 0 || _options.size() == 0 || _destructing;
}

void options_watcher::start()
Expand Down
1 change: 1 addition & 0 deletions src/core/options-watcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class options_watcher
std::thread _updater;
std::mutex _mutex;
std::condition_variable _stopping;
std::atomic_bool _destructing;
};


Expand Down
4 changes: 2 additions & 2 deletions src/sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ namespace librealsense

// Sometimes it is more efficient to prepare for large or repeating operations. Depending on the actual sensor
// type we might want to change power state or encapsulate small transactions into a large one.
virtual void prepare_for_bulk_operation() {};
virtual void finished_bulk_operation(){};
virtual void prepare_for_bulk_operation() {}
virtual void finished_bulk_operation(){}
};

// A sensor pointer to another "raw sensor", usually UVC/HID
Expand Down

0 comments on commit cd0b14e

Please sign in to comment.