1  package frost.threads
 2  
 3  ====================================================================================================
 4  An object which holds onto a [Lock] as long as the `ScopedLock` itself continues to exist.
 5  `ScopedLock` is typically assigned to a local variable, which will cause it to remain in memory
 6  until the local variable goes out of scope. For example:
 7  
 8      method process() {
 9          def scope := ScopedLock(lock)
10          ...
11          -- lock is automatically released at this point
12      }
13  ====================================================================================================
14  class ScopedLock : Immutable {
15      @private
16      def lock:Lock
17  
18      init(lock:Lock) {
19          self.lock := lock
20          lock.lock()
21      }
22  
23      @override
24      method cleanup() {
25          lock.unlock()
26      }
27  }