nv-facutil-idlock

1.0.2 • Public • Published

nv-facutil-idlock

  • simple promise sema

install

  • npm install nv-facutil-idlock

usage

   const {creat} = require("nv-facutil-idlock");      

example

        const pool = creat("idpool")

        /*
        > pool
        Pool [idpool] {}
        >
        */


         var lock0 = pool.acquire("abcdefg")
        /*
        > lock0
        true

        > pool.abcdefg.used_
        1
        > pool.abcdefg.pending_
        0
        >

        */


        var lock1 = pool.acquire("abcdefg")

        /*
        > lock1
        Promise {
          <pending>,
          [Symbol(async_id_symbol)]: 282,
          [Symbol(trigger_async_id_symbol)]: 5,
          [Symbol(destroyed)]: { destroyed: false }
        }

        > pool
        Pool [idpool] { abcdefg: Lock {} }
        >

        > pool.abcdefg.used_
        1
        > pool.abcdefg.pending_
        1
        >

        */


        pool.release("abcdefg")

        /*
        > pool
        Pool [idpool] { abcdefg: Lock {} }
        > pool.abcdefg.used_
        1
        > pool.abcdefg.pending_
        0
        >
        */

        pool.release("abcdefg")

        /*
        >
        true
        > pool
        Pool [idpool] {}
        >
        */

METHODS

Pool

 pool.acquire(id)                          
 pool.release(id)

 ////
 pool.aexec(id, ahandle:async ()=>{},rollback:async ()=>{})
 ////

 pool.ids_                 
 pool.size_
 pool.total_pending_      
 pool.total_used_

 pool.exist(id)

Lock

lock.id_;
lock.pool_;

lock.can_disconn();
lock._disconn();
lock.disconn();

lock'super.acquire()  
lock'super.release()

APIS

LICENSE

  • ISC

Readme

Keywords

none

Package Sidebar

Install

npm i nv-facutil-idlock

Weekly Downloads

3

Version

1.0.2

License

ISC

Unpacked Size

4.96 kB

Total Files

3

Last publish

Collaborators

  • ihgazni2