Yun-Sheng Chang 0e7c1e1b0b update
2025-02-12 23:04:16 -05:00

34 lines
781 B
Go

package lock
import (
"6.5840/kvtest1"
)
type Lock struct {
// IKVClerk is a go interface for k/v clerks: the interface hides
// the specific Clerk type of ck but promises that ck supports
// Put and Get. The tester passes the clerk in when calling
// MakeLock().
ck kvtest.IKVClerk
// You may add code here
}
// The tester calls MakeLock() and passes in a k/v clerk; your code can
// perform a Put or Get by calling lk.ck.Put() or lk.ck.Get().
//
// Use l as the key to store the "lock state" (you would have to decide
// precisely what the lock state is).
func MakeLock(ck kvtest.IKVClerk, l string) *Lock {
lk := &Lock{ck: ck}
// You may add code here
return lk
}
func (lk *Lock) Acquire() {
// Your code here
}
func (lk *Lock) Release() {
// Your code here
}