nv-auth-bit
v1.0.1
Published
nv-auth-bit ======================= - for inter process authenticate OR memory-management
Downloads
6
Readme
nv-auth-bit
- for inter process authenticate OR memory-management
install
- npm install nv-auth-bit
splitted
usage
const { s,c} = require("nv-auth-bit");
example
first creat a shmem
var shmem = s("nvauth_bit",1024*1024*8/*bytes*/);
/*
{
shmid: 2, //remeber this
bytsz: 8388608,
bitsz: 67108864, //remeber this
pathname: '/mnt/sda3/NV6-/nvauth/pkgs/nv-auth-bit/nvauth_bit'
}
*/
> process.pid
166069
>
/*
# ipcs
------ Message Queues --------
key msqid owner perms used-bytes messages
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x41020376 2 root 0 8388608 0
------ Semaphore Arrays --------
key semid owner perms nsems
*/
on other process
authenticate process
var shmid = 2;
var bitsz = 67108864;
var authen = c.creat_for_auther(shmid,bitsz);
/*
> authen
ForAuther {
id: 1, //maybe usable id
bits: {
is_any_fls: true,
is_any_tru: false,
are_all_fls: true,
are_all_tru: false,
count_of_0: 67108864,
count_of_1: 0,
bit_capacity: 67108864
}
}
>
*/
var id = authen.aloc(); // aloced id in auther
/*
>id
1
> authen
ForAuther {
id: 2,
bits: {
is_any_fls: true,
is_any_tru: true,
are_all_fls: false,
are_all_tru: false,
count_of_0: 67108863,
count_of_1: 1,
bit_capacity: 67108864
}
}
>
*/
> process.pid
171179
>
one handle process
var shmid = 2;
var bitsz = 67108864;
var for_handler = c.creat_for_handler(shmid,bitsz);
for_handler.is_valid(id/*aloced id in auther*/);
/*
ForHandler {
bits: {
is_any_fls: true,
is_any_tru: true,
are_all_fls: false,
are_all_tru: false,
count_of_0: 67108863,
count_of_1: 1,
bit_capacity: 67108864
}
}
*/
for_handler.free(id /*aloced id in auther*/);
for_handler.is_valid(id /*aloced id in auther*/);
/*
> for_handler
ForHandler {
bits: {
is_any_fls: true,
is_any_tru: false,
are_all_fls: true,
are_all_tru: false,
count_of_0: 67108864,
count_of_1: 0,
bit_capacity: 67108864
}
}
> process.pid
177568
> .
*/
METHODS
APIS
LICENSE
- ISC