You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
785 B

  1. package mount
  2. import (
  3. "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
  4. "sync"
  5. )
  6. type LockedEntry struct {
  7. *filer_pb.Entry
  8. sync.RWMutex
  9. }
  10. func (le *LockedEntry) GetEntry() *filer_pb.Entry {
  11. le.RLock()
  12. defer le.RUnlock()
  13. return le.Entry
  14. }
  15. func (le *LockedEntry) SetEntry(entry *filer_pb.Entry) {
  16. le.Lock()
  17. defer le.Unlock()
  18. le.Entry = entry
  19. }
  20. func (le *LockedEntry) UpdateEntry(fn func(entry *filer_pb.Entry)) *filer_pb.Entry {
  21. le.Lock()
  22. defer le.Unlock()
  23. fn(le.Entry)
  24. return le.Entry
  25. }
  26. func (le *LockedEntry) GetChunks() []*filer_pb.FileChunk {
  27. le.RLock()
  28. defer le.RUnlock()
  29. return le.Entry.Chunks
  30. }
  31. func (le *LockedEntry) AppendChunks(newChunks []*filer_pb.FileChunk) {
  32. le.Lock()
  33. defer le.Unlock()
  34. le.Entry.Chunks = append(le.Entry.Chunks, newChunks...)
  35. }