Giter Club home page Giter Club logo

Comments (10)

gaodq avatar gaodq commented on August 24, 2024

https://github.com/Qihoo360/slash/blob/95c3c6313b7b360490cd5d6673f2519e48452c4f/slash/src/slash_mutex.cc#L178-L180
如果是最后一个引用就从records_中删除了
在Lock里面也就不会找到这个ref_mutex了

from slash.

DavidLiuXh avatar DavidLiuXh commented on August 24, 2024

map的锁在是ref_mutex->Lock()之前被 unlock的, 理伦上还是有可能先earse + unref后又调用了Lock

from slash.

gaodq avatar gaodq commented on August 24, 2024

确实会。。额

from slash.

gaodq avatar gaodq commented on August 24, 2024

Lock()、Unlock()一般是在同一线程中按顺序使用,现实中不会发生Unlock(key)在Lock(key)之前的情况。

from slash.

KernelMaker avatar KernelMaker commented on August 24, 2024

@DavidLiuXh 我擦,老司机看slash,硬广:推荐看https://github.com/KernelMaker/rocksutil

from slash.

DavidLiuXh avatar DavidLiuXh commented on August 24, 2024

@KernelMaker 本来打算打Pink, 发现里面还用了slash

from slash.

DavidLiuXh avatar DavidLiuXh commented on August 24, 2024

@gaodq 公共接口的没法预测是不是在同一线程里, 要是同一线程应该都不用lock了吧.

from slash.

gaodq avatar gaodq commented on August 24, 2024

一个线程里的lock unlock操作不都应该是成对出现的吗

from slash.

DavidLiuXh avatar DavidLiuXh commented on August 24, 2024

@gaodq 没错, 所以在lock unlock这个操作可能同时出现在两个thread里,理伦上还是有可能先earse + unref后又调用了Lock

from slash.

gaodq avatar gaodq commented on August 24, 2024

ref_mutex指向的是一个key的锁,如果是同一个key,在两个thread里操作不会有问题,因为都是先lock;如果是不同的key那更不会存在问题了,因为操作的是不同的ref_mutex

from slash.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.