Skip to content

Commit

Permalink
hold th epower on for 2 sec
Browse files Browse the repository at this point in the history
  • Loading branch information
Nir-Az committed May 21, 2024
1 parent c71b3d3 commit 1ace0a4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/uvc-sensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ class uvc_sensor : public raw_sensor_base

void power_for_duration( std::chrono::steady_clock::duration timeout = std::chrono::milliseconds( 500 ) )
{
acquire_power();
std::weak_ptr< uvc_sensor > weak = std::dynamic_pointer_cast< uvc_sensor >( shared_from_this() );
if( auto strong = weak.lock() )
{
strong->acquire_power();
}

std::thread release_power_thread( [weak, timeout]()
{
std::this_thread::sleep_for( timeout );
Expand Down

0 comments on commit 1ace0a4

Please sign in to comment.