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

mutex.go 622 B

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
12345678910111213141516171819202122232425262728293031323334
  1. package publock
  2. import (
  3. "gitlink.org.cn/cloudream/jcs-pub/client/internal/publock/reqbuilder"
  4. "gitlink.org.cn/cloudream/jcs-pub/client/internal/publock/types"
  5. )
  6. type Mutex struct {
  7. pub *PubLock
  8. locked LockedRequest
  9. }
  10. func (m *Mutex) Unlock() {
  11. m.pub.release(m.locked.ReqID)
  12. }
  13. type MutexBuilder struct {
  14. reqbuilder.LockRequestBuilder[*MutexBuilder]
  15. pub *PubLock
  16. }
  17. func (b *MutexBuilder) Lock(opt ...AcquireOptionFn) (*Mutex, error) {
  18. lkd, err := b.pub.acquire(types.LockRequest{
  19. Locks: b.Locks,
  20. }, opt...)
  21. if err != nil {
  22. return nil, err
  23. }
  24. return &Mutex{
  25. pub: b.pub,
  26. locked: lkd,
  27. }, nil
  28. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。