-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.d.ts
70 lines (58 loc) · 1.82 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/// <reference types="node" />
type Shm<T> = (T & { key?: number });
type ShmMap = {
Buffer: Shm<Buffer>;
Int8Array: Shm<Int8Array>;
Uint8Array: Shm<Uint8Array>;
Uint8ClampedArray: Shm<Uint8ClampedArray>;
Int16Array: Shm<Int16Array>;
Uint16Array: Shm<Uint16Array>;
Int32Array: Shm<Int32Array>;
Uint32Array: Shm<Uint32Array>;
Float32Array: Shm<Float32Array>;
Float64Array: Shm<Float64Array>;
}
/**
* Create shared memory segment/object.
* Returns null if shm already exists.
*/
export function create<K extends keyof ShmMap = 'Buffer'>(count: number, typeKey?: K, key?: number | string, perm?: string): ShmMap[K] | null;
/**
* Get shared memory segment/object.
* Returns null if shm not exists.
*/
export function get<K extends keyof ShmMap = 'Buffer'>(key: number | string, typeKey?: K): ShmMap[K] | null;
/**
* Detach shared memory segment/object.
* For System V: If there are no other attaches for this segment, it will be destroyed.
* Returns 0 on destroy, 1 on detach, -1 on error
*/
export function detach(key: number | string, forceDestoy?: boolean): number;
/**
* Destroy shared memory segment/object.
*/
export function destroy(key: number | string): boolean;
/**
* Detach all created and getted shared memory segments/objects.
* Will be automatically called on process exit/termination.
*/
export function detachAll(): number;
/**
* Get total size of all *used* shared memory in bytes.
*/
export function getTotalSize(): number;
/**
* Get total size of all *created* shared memory in bytes.
*/
export function getTotalCreatedSize(): number;
/**
* Max length of shared memory segment (count of elements, not bytes).
* 2^31 for 64bit, 2^30 for 32bit.
*/
export const LengthMax: number;
/**
* Types of shared memory object
*/
export const BufferType: {
[key: string]: number;
}