Code Monkey home page Code Monkey logo

eglock's Introduction

eGLock

erlang的全局锁,不可重入。写这个的目的是考虑slg大地图场景的战斗会存在大乱斗,各个战斗目标血量处理需要全局锁处理。

Build

$ rebar3 compile

说明

eGLock 基于c++11 atomic  
其中要锁的key 不能是列表的字符串 原因是锁表的key会判断是否为list来区分是锁单key 还是锁列表
另外建议锁的key需要通过宏定义来生成 维护时好搜查删改
对于 tryLock和releaseLock的使用应该在try里面使用并在after调用releaseLock,就像这样:
try 
    true = eGLock:tryLock(KeyOrKeys),
    %% doSomeThing
catch C:R:S ->
    %% do error
after 
    eGLock:releaseLock(KeyOrKeys)
end.

eglock's People

Contributors

sismaker avatar

Stargazers

dengzhicong avatar  avatar jostar avatar lkness avatar

Watchers

 avatar

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.