Complete the code to ensure the booking system checks availability before confirming.
if slot.is_available() and not slot.[1](): slot.book()
The slot must not be locked by another process to allow booking, so is_locked is the correct check.
Complete the code to lock the slot before booking to handle concurrency.
def book_slot(slot): if slot.[1](): slot.lock() slot.book()
We must check if the slot is available before locking it to prevent double booking.
Fix the error in the concurrency control to prevent double booking.
def book_slot(slot): if slot.is_available(): slot.[1]() slot.book()
Locking the slot before booking prevents other processes from booking the same slot concurrently.
Fill both blanks to implement optimistic concurrency control in booking.
def book_slot(slot, version): if slot.version == [1]: slot.book() slot.version = [2]
Check the current version matches, then increment version after booking to detect conflicts.
Fill all three blanks to implement a thread-safe booking with locking and availability check.
def safe_book(slot): with slot.[1](): if slot.[2](): slot.[3]()
Use a lock context to ensure thread safety, check availability, then book the slot.