130. RAII

Question.6

A developer uses braces to limit interrupt-disabled duration:

void process() {
   prepare_data();
   {
       IntGuard lock;  // Disable interrupts
       write_to_hardware();
   }  // Re-enable interrupts
   post_process();  // Runs with interrupts enabled
}

What is the benefit of the inner braces?

Need Help? Refer to the Quick Guide below

Select Answer