balloc 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.MD +37 -7
- package/README.ar.md +31 -1
- package/README.en.md +37 -7
- package/README.es.md +31 -1
- package/README.jp.md +31 -1
- package/README.pt.md +36 -7
- package/README.zh.md +31 -1
- package/docs/API /342/200/224 balloc.ar.md" +56 -0
- package/docs/API /342/200/224 balloc.en.md" +55 -0
- package/docs/API /342/200/224 balloc.es.md" +56 -0
- package/docs/API /342/200/224 balloc.jp.md" +56 -0
- package/docs/API /342/200/224 balloc.pt.md" +56 -0
- package/docs/API /342/200/224 balloc.zh.md" +56 -0
- package/package.json +1 -1
- package/src/ar/balloc.cjs +54 -24
- package/src/ar/balloc.js +1 -1
- package/src/ar/balloc.mjs +71 -28
- package/src/en/balloc.cjs +56 -24
- package/src/en/balloc.js +1 -1
- package/src/en/balloc.mjs +73 -28
- package/src/es/balloc.cjs +56 -24
- package/src/es/balloc.js +1 -1
- package/src/es/balloc.mjs +73 -28
- package/src/jp/balloc.cjs +56 -24
- package/src/jp/balloc.js +1 -1
- package/src/jp/balloc.mjs +73 -28
- package/src/pt/balloc.cjs +56 -23
- package/src/pt/balloc.js +1 -1
- package/src/pt/balloc.mjs +79 -28
- package/src/zh/balloc.cjs +54 -24
- package/src/zh/balloc.js +1 -1
- package/src/zh/balloc.mjs +71 -28
- package/types/ar/balloc.d.mts +32 -1
- package/types/en/balloc.d.mts +34 -1
- package/types/es/balloc.d.mts +34 -1
- package/types/jp/balloc.d.mts +34 -1
- package/types/pt/balloc.d.mts +37 -0
- package/types/zh/balloc.d.mts +32 -1
package/src/zh/balloc.mjs
CHANGED
|
@@ -104,6 +104,15 @@ const isTypedArray = (val) => ArrayBuffer.isView(val) && !(val instanceof DataVi
|
|
|
104
104
|
/**
|
|
105
105
|
* 带有 ReBump GC 的 Echo 栈双总线指针碰撞分配器(Dual Bus Bump Allocator)。
|
|
106
106
|
*/
|
|
107
|
+
/**
|
|
108
|
+
* 用于数据导入的同步适配器契约。
|
|
109
|
+
*
|
|
110
|
+
* 适配器接收 Balloc 实例,并使用其公共 API 存储数据,返回用于标识主内存块的句柄。
|
|
111
|
+
*
|
|
112
|
+
* @typedef {Object} FormatAdapter
|
|
113
|
+
* @property {(allocator: Balloc) => number} load - 将数据加载到分配器并返回相应的句柄。
|
|
114
|
+
*/
|
|
115
|
+
|
|
107
116
|
export default class Balloc {
|
|
108
117
|
|
|
109
118
|
/**
|
|
@@ -256,12 +265,15 @@ export default class Balloc {
|
|
|
256
265
|
const occupied = this.controlAdapter.getUint32(headerAddress + OCCUPIED_OFFSET, IS_LITTLE_ENDIAN);
|
|
257
266
|
const capacity = this.controlAdapter.getUint8(headerAddress + CAPACITY_OFFSET);
|
|
258
267
|
const cookie = this.controlAdapter.getUint8(headerAddress + COOKIE_OFFSET);
|
|
268
|
+
const borrowed = this.controlAdapter.getUint8(headerAddress + FLAGS_OFFSET) & VIEW_LOCK;
|
|
259
269
|
|
|
260
270
|
if (cookie !== this.bakeCookie(headerAddress, generation)) {
|
|
261
271
|
throw new Error("Invalid or corrupted handle");
|
|
262
272
|
}
|
|
263
273
|
|
|
264
|
-
|
|
274
|
+
if (borrowed) {
|
|
275
|
+
throw new Error("Block is borrowed");
|
|
276
|
+
}
|
|
265
277
|
|
|
266
278
|
if (capacity >= 31) throw new AggregateError([new Error("Can´t reallocate handler."), new RangeError("Capacity has reached its limit.")], "Internal Error.");
|
|
267
279
|
|
|
@@ -308,7 +320,7 @@ export default class Balloc {
|
|
|
308
320
|
*/
|
|
309
321
|
shrink(handler) {
|
|
310
322
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
311
|
-
|
|
323
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
312
324
|
|
|
313
325
|
const newCapacity = Math.max(1, 32 - Math.clz32(Math.max(2, meta.occupied) - 1));
|
|
314
326
|
if (newCapacity >= meta.capacityExponent) return;
|
|
@@ -339,12 +351,15 @@ export default class Balloc {
|
|
|
339
351
|
const dataAddress = this.controlAdapter.getUint32(headerAddress + ADDRESS_OFFSET, IS_LITTLE_ENDIAN);
|
|
340
352
|
const capacity = this.controlAdapter.getUint8(headerAddress + CAPACITY_OFFSET);
|
|
341
353
|
const cookie = this.controlAdapter.getUint8(headerAddress + COOKIE_OFFSET);
|
|
354
|
+
const borrowed = this.controlAdapter.getUint8(headerAddress + FLAGS_OFFSET) & VIEW_LOCK;
|
|
342
355
|
|
|
343
356
|
if (cookie !== this.bakeCookie(headerAddress, generation)) {
|
|
344
357
|
throw new Error("Invalid or corrupted handle");
|
|
345
358
|
}
|
|
346
359
|
|
|
347
|
-
|
|
360
|
+
if (borrowed) {
|
|
361
|
+
throw new Error("Block is borrowed");
|
|
362
|
+
}
|
|
348
363
|
|
|
349
364
|
const blockSize = (1 << capacity >>> 0) * this.wordSize;
|
|
350
365
|
this.controlAdapter.setUint8(headerAddress + COOKIE_OFFSET, 0);
|
|
@@ -534,7 +549,7 @@ export default class Balloc {
|
|
|
534
549
|
*/
|
|
535
550
|
push(handler, value) {
|
|
536
551
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
537
|
-
|
|
552
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
538
553
|
|
|
539
554
|
if ((meta.occupied + 1) * this.wordSize > meta.byteCapacity) return false;
|
|
540
555
|
|
|
@@ -556,7 +571,7 @@ export default class Balloc {
|
|
|
556
571
|
*/
|
|
557
572
|
pop(handler) {
|
|
558
573
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
559
|
-
|
|
574
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
560
575
|
|
|
561
576
|
if (meta.occupied === 0) return undefined;
|
|
562
577
|
|
|
@@ -596,7 +611,7 @@ export default class Balloc {
|
|
|
596
611
|
*/
|
|
597
612
|
nudge(handler, value) {
|
|
598
613
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
599
|
-
|
|
614
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
600
615
|
|
|
601
616
|
if ((meta.occupied + 1) * this.wordSize > meta.byteCapacity) return false;
|
|
602
617
|
|
|
@@ -620,7 +635,7 @@ export default class Balloc {
|
|
|
620
635
|
*/
|
|
621
636
|
pull(handler) {
|
|
622
637
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
623
|
-
|
|
638
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
624
639
|
|
|
625
640
|
if (meta.occupied === 0) return undefined;
|
|
626
641
|
|
|
@@ -751,7 +766,7 @@ export default class Balloc {
|
|
|
751
766
|
*/
|
|
752
767
|
set(handler, index, value) {
|
|
753
768
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
754
|
-
|
|
769
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
755
770
|
|
|
756
771
|
if (index < 0 || index >= meta.occupied) return false;
|
|
757
772
|
|
|
@@ -774,7 +789,7 @@ export default class Balloc {
|
|
|
774
789
|
*/
|
|
775
790
|
clear(handler, value = 0) {
|
|
776
791
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
777
|
-
|
|
792
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
778
793
|
|
|
779
794
|
const slots = meta.byteCapacity / this.wordSize;
|
|
780
795
|
const rawAddress = meta.dataAddress >>> this.wordShift;
|
|
@@ -802,7 +817,7 @@ export default class Balloc {
|
|
|
802
817
|
*/
|
|
803
818
|
fill(handler, value, start = 0, end = null) {
|
|
804
819
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
805
|
-
|
|
820
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
806
821
|
|
|
807
822
|
const slots = meta.byteCapacity / this.wordSize;
|
|
808
823
|
const lastIndex = end ?? slots;
|
|
@@ -834,7 +849,7 @@ export default class Balloc {
|
|
|
834
849
|
*/
|
|
835
850
|
fillAll(handler, value) {
|
|
836
851
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
837
|
-
|
|
852
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
838
853
|
|
|
839
854
|
const rawAddress = meta.dataAddress >>> this.wordShift;
|
|
840
855
|
const capacityElements = meta.byteCapacity / this.wordSize;
|
|
@@ -860,7 +875,7 @@ export default class Balloc {
|
|
|
860
875
|
*/
|
|
861
876
|
put(handler, data) {
|
|
862
877
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
863
|
-
|
|
878
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
864
879
|
|
|
865
880
|
const rawAddress = meta.dataAddress >>> this.wordShift;
|
|
866
881
|
const length = Math.min(1 << meta.capacityExponent >>> 0, data.length);
|
|
@@ -923,26 +938,30 @@ export default class Balloc {
|
|
|
923
938
|
if (typeof callback !== "function") throw new TypeError("callback must be a function");
|
|
924
939
|
|
|
925
940
|
const lookup = Object.create(null);
|
|
941
|
+
const acquired = [];
|
|
926
942
|
const views = [];
|
|
927
943
|
|
|
928
944
|
try {
|
|
929
|
-
for(let i = 0; i < lastIndex; i++) {
|
|
930
|
-
const metadata = this.extractMetadata(args[i],
|
|
945
|
+
for (let i = 0; i < lastIndex; i++) {
|
|
946
|
+
const metadata = this.extractMetadata(args[i], this.metadata);
|
|
947
|
+
const headerAddr = metadata.headerAddress;
|
|
948
|
+
|
|
949
|
+
|
|
950
|
+
if (Object.hasOwn(lookup, headerAddr)) throw new Error("Duplicate handler");
|
|
951
|
+
if (metadata.borrowed) throw new Error("Block is already borrowed");
|
|
931
952
|
|
|
932
|
-
|
|
933
|
-
if (Object.hasOwn(lookup, metadata.headerAddress)) throw new Error("Duplicate handler");
|
|
934
|
-
if (metadata.borrowed) throw new Error("Block is already borrowed");
|
|
935
|
-
|
|
936
|
-
this.controlBus[metadata.headerAddress + FLAGS_OFFSET] |= VIEW_LOCK;
|
|
953
|
+
this.controlBus[headerAddr + FLAGS_OFFSET] |= VIEW_LOCK;
|
|
937
954
|
|
|
938
955
|
const rawAddress = metadata.dataAddress >>> this.wordShift;
|
|
939
|
-
lookup[
|
|
956
|
+
lookup[headerAddr] = true;
|
|
957
|
+
acquired.push(headerAddr);
|
|
958
|
+
|
|
940
959
|
views.push(this.auxiliary.subarray(rawAddress, rawAddress + metadata.occupied))
|
|
941
960
|
}
|
|
942
961
|
return callback(...views);
|
|
943
962
|
} finally {
|
|
944
|
-
for (
|
|
945
|
-
this.controlBus[
|
|
963
|
+
for (let i = 0; i < acquired.length; i++) {
|
|
964
|
+
this.controlBus[acquired[i] + FLAGS_OFFSET] &= ~VIEW_LOCK;
|
|
946
965
|
}
|
|
947
966
|
}
|
|
948
967
|
}
|
|
@@ -1032,7 +1051,7 @@ export default class Balloc {
|
|
|
1032
1051
|
|
|
1033
1052
|
this.extractMetadata(source, metaA);
|
|
1034
1053
|
this.extractMetadata(destination, metaB);
|
|
1035
|
-
|
|
1054
|
+
if (metaB.borrowed) throw new Error("Block is borrowed");
|
|
1036
1055
|
|
|
1037
1056
|
const maxSlotsDest = Math.floor(metaB.byteCapacity / this.wordSize);
|
|
1038
1057
|
const slotsToCopy = Math.min(metaA.occupied, maxSlotsDest, slots);
|
|
@@ -1062,7 +1081,7 @@ export default class Balloc {
|
|
|
1062
1081
|
*/
|
|
1063
1082
|
copyWithin(handler, target, start, length) {
|
|
1064
1083
|
const meta = this.extractMetadata(handler, this.metadata);
|
|
1065
|
-
|
|
1084
|
+
if (meta.borrowed) throw new Error("Block is borrowed");
|
|
1066
1085
|
|
|
1067
1086
|
const slots = Math.floor(meta.byteCapacity / this.wordSize);
|
|
1068
1087
|
target = Math.trunc(target);
|
|
@@ -1109,7 +1128,8 @@ export default class Balloc {
|
|
|
1109
1128
|
|
|
1110
1129
|
this.extractMetadata(target, metaTarget);
|
|
1111
1130
|
this.extractMetadata(source, metaSource);
|
|
1112
|
-
|
|
1131
|
+
if (metaTarget.borrowed) throw new Error("Block is borrowed");
|
|
1132
|
+
|
|
1113
1133
|
|
|
1114
1134
|
const available = metaTarget.byteCapacity / this.wordSize - metaTarget.occupied;
|
|
1115
1135
|
const count = Math.min(available, metaSource.occupied);
|
|
@@ -1172,8 +1192,9 @@ export default class Balloc {
|
|
|
1172
1192
|
this.extractMetadata(source, metaA);
|
|
1173
1193
|
this.extractMetadata(target, metaB);
|
|
1174
1194
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1195
|
+
if (metaA.borrowed) throw new Error("Block is borrowed");
|
|
1196
|
+
if (metaB.borrowed) throw new Error("Block is borrowed");
|
|
1197
|
+
|
|
1177
1198
|
|
|
1178
1199
|
this.controlAdapter.setUint32(metaA.headerAddress + ADDRESS_OFFSET, metaB.dataAddress, IS_LITTLE_ENDIAN);
|
|
1179
1200
|
this.controlAdapter.setUint32(metaB.headerAddress + ADDRESS_OFFSET, metaA.dataAddress, IS_LITTLE_ENDIAN);
|
|
@@ -1284,6 +1305,27 @@ export default class Balloc {
|
|
|
1284
1305
|
return handler;
|
|
1285
1306
|
}
|
|
1286
1307
|
|
|
1308
|
+
// ========== 数据集成与导入 ==========
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* 通过专用适配器加载数据。
|
|
1312
|
+
*
|
|
1313
|
+
* 适配器接收此实例,并使用其公共 API 分配和填充所需的内存块。
|
|
1314
|
+
* 数据的组织和解释完全由适配器负责;Balloc 仅委托该操作并返回
|
|
1315
|
+
* 适配器生成的句柄。
|
|
1316
|
+
*
|
|
1317
|
+
* 此操作为同步操作。适配器必须在返回前完成数据导入;如果加载
|
|
1318
|
+
* 失败,适配器负责回滚自身的分配。
|
|
1319
|
+
*
|
|
1320
|
+
* @param {FormatAdapter} adapter - 实现 load(allocator) 的适配器。
|
|
1321
|
+
* @returns {number} 适配器返回的句柄。
|
|
1322
|
+
* @throws {TypeError} 适配器未实现 load() 方法时。
|
|
1323
|
+
* @throws {Error} 适配器拒绝所提供的基础设施时。
|
|
1324
|
+
*/
|
|
1325
|
+
loadData(adapter) {
|
|
1326
|
+
if (!adapter || typeof adapter.load !== "function") throw new TypeError("adapter must implement load(allocator)");
|
|
1327
|
+
return adapter.load(this);
|
|
1328
|
+
}
|
|
1287
1329
|
// ============= 工具 (UTILITIES) ==============
|
|
1288
1330
|
|
|
1289
1331
|
/**
|
|
@@ -1295,7 +1337,8 @@ export default class Balloc {
|
|
|
1295
1337
|
* @returns {void}
|
|
1296
1338
|
* @throws {Error} 如果块正通过 withView() 被借用。
|
|
1297
1339
|
* @private
|
|
1298
|
-
|
|
1340
|
+
* @deprecated
|
|
1341
|
+
*/
|
|
1299
1342
|
assertNotBorrowed(headerAddress) {
|
|
1300
1343
|
if (this.controlBus[headerAddress + FLAGS_OFFSET] & VIEW_LOCK) {
|
|
1301
1344
|
throw new Error("Block is borrowed");
|
package/types/ar/balloc.d.mts
CHANGED
|
@@ -29,9 +29,23 @@ export type Metadata = {
|
|
|
29
29
|
*/
|
|
30
30
|
borrowed: number;
|
|
31
31
|
};
|
|
32
|
+
export type FormatAdapter = {
|
|
33
|
+
/**
|
|
34
|
+
* - يحمّل البيانات إلى المخصّص ويعيد المعالج المقابل.
|
|
35
|
+
*/
|
|
36
|
+
load: (allocator: Balloc) => number;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
39
|
* مخصص الذاكرة المتقاطع ذو الحافتين مع مكدس صدى وإدارة النفايات ReBump.
|
|
34
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* عقد محوّل متزامن لإدخال البيانات.
|
|
43
|
+
*
|
|
44
|
+
* يتلقى المحوّل نسخة Balloc ويستخدم واجهتها العامة لتخزين البيانات، ثم يعيد المعالج الذي يحدد الكتلة الرئيسية.
|
|
45
|
+
*
|
|
46
|
+
* @typedef {Object} FormatAdapter
|
|
47
|
+
* @property {(allocator: Balloc) => number} load - يحمّل البيانات إلى المخصّص ويعيد المعالج المقابل.
|
|
48
|
+
*/
|
|
35
49
|
export default class Balloc {
|
|
36
50
|
wordType: BucketType;
|
|
37
51
|
bucketType: string;
|
|
@@ -642,6 +656,22 @@ export default class Balloc {
|
|
|
642
656
|
* @throws {Error} إذا كان نوع كلمة البيانات المفككة يختلف عن المُكوّن في المخصص.
|
|
643
657
|
*/
|
|
644
658
|
load(serialized: Uint8Array | ArrayBuffer): number;
|
|
659
|
+
/**
|
|
660
|
+
* يحمّل البيانات من خلال محوّل متخصص.
|
|
661
|
+
*
|
|
662
|
+
* يتلقى المحوّل هذا المثيل ويستخدم واجهته العامة لتخصيص الكتل المطلوبة
|
|
663
|
+
* وملئها. تقع مسؤولية تنظيم البيانات وتفسيرها بالكامل على عاتق المحوّل؛
|
|
664
|
+
* أما Balloc فيفوّض العملية فقط ويعيد المعالج الناتج.
|
|
665
|
+
*
|
|
666
|
+
* العملية متزامنة. يجب على المحوّل إكمال إدخال البيانات قبل الإرجاع،
|
|
667
|
+
* وهو مسؤول عن التراجع عن تخصيصاته إذا فشلت عملية التحميل.
|
|
668
|
+
*
|
|
669
|
+
* @param {FormatAdapter} adapter - محوّل يطبّق load(allocator).
|
|
670
|
+
* @returns {number} المعالج الذي يعيده المحوّل.
|
|
671
|
+
* @throws {TypeError} إذا لم يطبّق المحوّل الدالة load().
|
|
672
|
+
* @throws {Error} إذا رفض المحوّل البنية التحتية المقدمة.
|
|
673
|
+
*/
|
|
674
|
+
loadData(adapter: FormatAdapter): number;
|
|
645
675
|
/**
|
|
646
676
|
* يمنع عمليات التعديل على كتلة معارة.
|
|
647
677
|
*
|
|
@@ -651,7 +681,8 @@ export default class Balloc {
|
|
|
651
681
|
* @returns {void}
|
|
652
682
|
* @throws {Error} إذا كانت الكتلة معارة بواسطة withView().
|
|
653
683
|
* @private
|
|
654
|
-
|
|
684
|
+
* @deprecated
|
|
685
|
+
*/
|
|
655
686
|
private assertNotBorrowed;
|
|
656
687
|
/**
|
|
657
688
|
* يمنع العمليات التي تستبدل أو تعيد تعيين dataBus
|
package/types/en/balloc.d.mts
CHANGED
|
@@ -29,9 +29,23 @@ export type Metadata = {
|
|
|
29
29
|
*/
|
|
30
30
|
borrowed: number;
|
|
31
31
|
};
|
|
32
|
+
export type FormatAdapter = {
|
|
33
|
+
/**
|
|
34
|
+
* - Loads data into the allocator and returns the corresponding handler.
|
|
35
|
+
*/
|
|
36
|
+
load: (allocator: Balloc) => number;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
39
|
* Echo Stack Dual Bus Bump Allocator with ReBump GC.
|
|
34
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* Synchronous adapter contract for data ingestion.
|
|
43
|
+
*
|
|
44
|
+
* The adapter receives the Balloc instance and uses its public API to store data, returning the handler that identifies the primary block.
|
|
45
|
+
*
|
|
46
|
+
* @typedef {Object} FormatAdapter
|
|
47
|
+
* @property {(allocator: Balloc) => number} load - Loads data into the allocator and returns the corresponding handler.
|
|
48
|
+
*/
|
|
35
49
|
export default class Balloc {
|
|
36
50
|
wordType: BucketType;
|
|
37
51
|
bucketType: string;
|
|
@@ -668,6 +682,24 @@ export default class Balloc {
|
|
|
668
682
|
* @throws {Error} If the decoded data's word type differs from the allocator's configuration.
|
|
669
683
|
*/
|
|
670
684
|
load(serialized: Uint8Array | ArrayBuffer): number;
|
|
685
|
+
/**
|
|
686
|
+
* Loads data through a specialized adapter.
|
|
687
|
+
*
|
|
688
|
+
* The adapter receives this instance and uses its public API to allocate
|
|
689
|
+
* and populate the required blocks. Data organization and interpretation
|
|
690
|
+
* are the adapter's sole responsibility; Balloc only delegates the
|
|
691
|
+
* operation and returns the resulting handler.
|
|
692
|
+
*
|
|
693
|
+
* The operation is synchronous. The adapter must complete ingestion before
|
|
694
|
+
* returning and is responsible for reverting its own allocations if
|
|
695
|
+
* loading fails.
|
|
696
|
+
*
|
|
697
|
+
* @param {FormatAdapter} adapter - Adapter implementing load(allocator).
|
|
698
|
+
* @returns {number} Handler returned by the adapter.
|
|
699
|
+
* @throws {TypeError} If the adapter does not implement load().
|
|
700
|
+
* @throws {Error} If the adapter rejects the subscribed infrastructure.
|
|
701
|
+
*/
|
|
702
|
+
loadData(adapter: FormatAdapter): number;
|
|
671
703
|
/**
|
|
672
704
|
* Prevents modification operations on a borrowed block.
|
|
673
705
|
*
|
|
@@ -677,7 +709,8 @@ export default class Balloc {
|
|
|
677
709
|
* @returns {void}
|
|
678
710
|
* @throws {Error} If the block is borrowed via withView().
|
|
679
711
|
* @private
|
|
680
|
-
|
|
712
|
+
* @deprecated
|
|
713
|
+
*/
|
|
681
714
|
private assertNotBorrowed;
|
|
682
715
|
/**
|
|
683
716
|
* Prevents operations that replace or remap the dataBus
|
package/types/es/balloc.d.mts
CHANGED
|
@@ -29,9 +29,23 @@ export type Metadata = {
|
|
|
29
29
|
*/
|
|
30
30
|
borrowed: number;
|
|
31
31
|
};
|
|
32
|
+
export type FormatAdapter = {
|
|
33
|
+
/**
|
|
34
|
+
* - Carga los datos en el asignador y devuelve el handler correspondiente.
|
|
35
|
+
*/
|
|
36
|
+
load: (allocator: Balloc) => number;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
39
|
* Asignador tipo Bump de doble bus con pila de eco y recolección de basura ReBump.
|
|
34
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* Contrato de un adaptador síncrono para la ingesta de datos.
|
|
43
|
+
*
|
|
44
|
+
* El adaptador recibe la instancia de Balloc y utiliza su API pública para almacenar los datos, devolviendo el handler que identifica el bloque principal.
|
|
45
|
+
*
|
|
46
|
+
* @typedef {Object} FormatAdapter
|
|
47
|
+
* @property {(allocator: Balloc) => number} load - Carga los datos en el asignador y devuelve el handler correspondiente.
|
|
48
|
+
*/
|
|
35
49
|
export default class Balloc {
|
|
36
50
|
wordType: BucketType;
|
|
37
51
|
bucketType: string;
|
|
@@ -656,6 +670,24 @@ export default class Balloc {
|
|
|
656
670
|
* @throws {Error} Si el tipo de palabra del dato decodificado difiere del configurado en el asignador.
|
|
657
671
|
*/
|
|
658
672
|
load(serialized: Uint8Array | ArrayBuffer): number;
|
|
673
|
+
/**
|
|
674
|
+
* Carga datos mediante un adaptador especializado.
|
|
675
|
+
*
|
|
676
|
+
* El adaptador recibe esta instancia y utiliza su API pública para asignar
|
|
677
|
+
* y completar los bloques necesarios. La organización y la interpretación
|
|
678
|
+
* de los datos son responsabilidad exclusiva del adaptador; Balloc solo
|
|
679
|
+
* delega la operación y devuelve el handler resultante.
|
|
680
|
+
*
|
|
681
|
+
* La operación es síncrona. El adaptador debe completar la ingesta antes
|
|
682
|
+
* de retornar y es responsable de revertir sus propias asignaciones si
|
|
683
|
+
* ocurre un error durante la carga.
|
|
684
|
+
*
|
|
685
|
+
* @param {FormatAdapter} adapter - Adaptador que implementa load(allocator).
|
|
686
|
+
* @returns {number} Handler devuelto por el adaptador.
|
|
687
|
+
* @throws {TypeError} Si el adaptador no implementa el método load().
|
|
688
|
+
* @throws {Error} Si el adaptador rechaza la infraestructura suscrita.
|
|
689
|
+
*/
|
|
690
|
+
loadData(adapter: FormatAdapter): number;
|
|
659
691
|
/**
|
|
660
692
|
* Impide operaciones de modificación sobre un bloque prestado.
|
|
661
693
|
*
|
|
@@ -665,7 +697,8 @@ export default class Balloc {
|
|
|
665
697
|
* @returns {void}
|
|
666
698
|
* @throws {Error} Si el bloque está prestado mediante `withView()`.
|
|
667
699
|
* @private
|
|
668
|
-
|
|
700
|
+
* @deprecated
|
|
701
|
+
*/
|
|
669
702
|
private assertNotBorrowed;
|
|
670
703
|
/**
|
|
671
704
|
* Impide operaciones que reemplazan o reasignan el `dataBus`
|
package/types/jp/balloc.d.mts
CHANGED
|
@@ -29,9 +29,23 @@ export type Metadata = {
|
|
|
29
29
|
*/
|
|
30
30
|
borrowed: number;
|
|
31
31
|
};
|
|
32
|
+
export type FormatAdapter = {
|
|
33
|
+
/**
|
|
34
|
+
* - アロケーターにデータを読み込み、対応するハンドラーを返します。
|
|
35
|
+
*/
|
|
36
|
+
load: (allocator: Balloc) => number;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
39
|
* ReBump GCを備えたEcho Stackデュアルバス・バンプアロケータ。
|
|
34
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* データ取り込み用の同期アダプター契約。
|
|
43
|
+
*
|
|
44
|
+
* アダプターは Balloc インスタンスを受け取り、その公開 API を使用してデータを格納し、主要ブロックを識別するハンドラーを返します。
|
|
45
|
+
*
|
|
46
|
+
* @typedef {Object} FormatAdapter
|
|
47
|
+
* @property {(allocator: Balloc) => number} load - アロケーターにデータを読み込み、対応するハンドラーを返します。
|
|
48
|
+
*/
|
|
35
49
|
export default class Balloc {
|
|
36
50
|
wordType: BucketType;
|
|
37
51
|
bucketType: string;
|
|
@@ -605,6 +619,24 @@ export default class Balloc {
|
|
|
605
619
|
* @throws {Error} デコードされたデータのワード型がアロケータの設定と異なる場合。
|
|
606
620
|
*/
|
|
607
621
|
load(serialized: Uint8Array | ArrayBuffer): number;
|
|
622
|
+
/**
|
|
623
|
+
* 専用アダプターを通じてデータを読み込みます。
|
|
624
|
+
*
|
|
625
|
+
* アダプターはこのインスタンスを受け取り、その公開 API を使用して
|
|
626
|
+
* 必要なブロックを割り当て、データを書き込みます。データの構成と
|
|
627
|
+
* 解釈はアダプターのみが担当し、Balloc は処理を委譲して生成された
|
|
628
|
+
* ハンドラーを返します。
|
|
629
|
+
*
|
|
630
|
+
* この操作は同期的に実行されます。アダプターは戻る前にデータの
|
|
631
|
+
* 取り込みを完了し、読み込みに失敗した場合は自身の割り当てを
|
|
632
|
+
* 元に戻す責任を負います。
|
|
633
|
+
*
|
|
634
|
+
* @param {FormatAdapter} adapter - load(allocator) を実装するアダプター。
|
|
635
|
+
* @returns {number} アダプターが返すハンドラー。
|
|
636
|
+
* @throws {TypeError} アダプターが load() メソッドを実装していない場合。
|
|
637
|
+
* @throws {Error} アダプターが指定されたインフラストラクチャを拒否した場合。
|
|
638
|
+
*/
|
|
639
|
+
loadData(adapter: FormatAdapter): number;
|
|
608
640
|
/**
|
|
609
641
|
* 借用中のブロックに対する変更操作を禁止します。
|
|
610
642
|
*
|
|
@@ -614,7 +646,8 @@ export default class Balloc {
|
|
|
614
646
|
* @returns {void}
|
|
615
647
|
* @throws {Error} ブロックが withView() によって借用されている場合。
|
|
616
648
|
* @private
|
|
617
|
-
|
|
649
|
+
* @deprecated
|
|
650
|
+
*/
|
|
618
651
|
private assertNotBorrowed;
|
|
619
652
|
/**
|
|
620
653
|
* いずれかのセグメントが借用されている間、dataBus を置き換える
|
package/types/pt/balloc.d.mts
CHANGED
|
@@ -29,6 +29,23 @@ export type Metadata = {
|
|
|
29
29
|
*/
|
|
30
30
|
borrowed: number;
|
|
31
31
|
};
|
|
32
|
+
export type FormatAdapter = {
|
|
33
|
+
/**
|
|
34
|
+
* - Carrega os dados no alocador
|
|
35
|
+
* e retorna o handler correspondente.
|
|
36
|
+
*/
|
|
37
|
+
load: (allocator: Balloc) => number;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Contrato de um adaptador síncrono para ingestão de dados.
|
|
41
|
+
*
|
|
42
|
+
* O adaptador recebe a instância do Balloc e utiliza sua API pública para
|
|
43
|
+
* armazenar os dados, retornando o handler que identifica o bloco principal.
|
|
44
|
+
*
|
|
45
|
+
* @typedef {Object} FormatAdapter
|
|
46
|
+
* @property {(allocator: Balloc) => number} load - Carrega os dados no alocador
|
|
47
|
+
* e retorna o handler correspondente.
|
|
48
|
+
*/
|
|
32
49
|
/**
|
|
33
50
|
* Echo Stack Dual Bus Bump Allocator with ReBump GC.
|
|
34
51
|
*/
|
|
@@ -661,6 +678,25 @@ export default class Balloc {
|
|
|
661
678
|
*/
|
|
662
679
|
load(serialized: Uint8Array | ArrayBuffer): number;
|
|
663
680
|
/**
|
|
681
|
+
* Carrega dados por meio de um adaptador especializado.
|
|
682
|
+
*
|
|
683
|
+
* O adaptador recebe esta instância e utiliza sua API pública para alocar
|
|
684
|
+
* e preencher os blocos necessários. A organização e a interpretação dos
|
|
685
|
+
* dados são responsabilidade exclusiva do adaptador; o Balloc apenas
|
|
686
|
+
* delega a operação e retorna o handler produzido.
|
|
687
|
+
*
|
|
688
|
+
* A operação é síncrona. O adaptador deve concluir a ingestão antes de
|
|
689
|
+
* retornar e é responsável por reverter suas próprias alocações caso
|
|
690
|
+
* ocorra uma falha durante o carregamento.
|
|
691
|
+
*
|
|
692
|
+
* @param {FormatAdapter} adapter - Adaptador que implementa load(allocator).
|
|
693
|
+
* @returns {number} Handler retornado pelo adaptador.
|
|
694
|
+
* @throws {TypeError} Se o adaptador não implementar o método load().
|
|
695
|
+
* @throws {Error} Se o adaptador recusar a infraestrutura subscrita.
|
|
696
|
+
*/
|
|
697
|
+
loadData(adapter: FormatAdapter): number;
|
|
698
|
+
/**
|
|
699
|
+
* [OBSOLETO]
|
|
664
700
|
* Impede operações de modificação sobre um bloco emprestado.
|
|
665
701
|
*
|
|
666
702
|
* Verifica a flag VIEW_LOCK no header associado ao endereço informado.
|
|
@@ -668,6 +704,7 @@ export default class Balloc {
|
|
|
668
704
|
* @param {number} headerAddress - Endereço do header no controlBus.
|
|
669
705
|
* @returns {void}
|
|
670
706
|
* @throws {Error} Se o bloco estiver emprestado por withView().
|
|
707
|
+
* @deprecated
|
|
671
708
|
* @private
|
|
672
709
|
*/
|
|
673
710
|
private assertNotBorrowed;
|
package/types/zh/balloc.d.mts
CHANGED
|
@@ -29,9 +29,23 @@ export type Metadata = {
|
|
|
29
29
|
*/
|
|
30
30
|
borrowed: number;
|
|
31
31
|
};
|
|
32
|
+
export type FormatAdapter = {
|
|
33
|
+
/**
|
|
34
|
+
* - 将数据加载到分配器并返回相应的句柄。
|
|
35
|
+
*/
|
|
36
|
+
load: (allocator: Balloc) => number;
|
|
37
|
+
};
|
|
32
38
|
/**
|
|
33
39
|
* 带有 ReBump GC 的 Echo 栈双总线指针碰撞分配器(Dual Bus Bump Allocator)。
|
|
34
40
|
*/
|
|
41
|
+
/**
|
|
42
|
+
* 用于数据导入的同步适配器契约。
|
|
43
|
+
*
|
|
44
|
+
* 适配器接收 Balloc 实例,并使用其公共 API 存储数据,返回用于标识主内存块的句柄。
|
|
45
|
+
*
|
|
46
|
+
* @typedef {Object} FormatAdapter
|
|
47
|
+
* @property {(allocator: Balloc) => number} load - 将数据加载到分配器并返回相应的句柄。
|
|
48
|
+
*/
|
|
35
49
|
export default class Balloc {
|
|
36
50
|
wordType: BucketType;
|
|
37
51
|
bucketType: string;
|
|
@@ -563,6 +577,22 @@ export default class Balloc {
|
|
|
563
577
|
* @throws {Error} 如果解码数据的字类型与分配器配置的不一致。
|
|
564
578
|
*/
|
|
565
579
|
load(serialized: Uint8Array | ArrayBuffer): number;
|
|
580
|
+
/**
|
|
581
|
+
* 通过专用适配器加载数据。
|
|
582
|
+
*
|
|
583
|
+
* 适配器接收此实例,并使用其公共 API 分配和填充所需的内存块。
|
|
584
|
+
* 数据的组织和解释完全由适配器负责;Balloc 仅委托该操作并返回
|
|
585
|
+
* 适配器生成的句柄。
|
|
586
|
+
*
|
|
587
|
+
* 此操作为同步操作。适配器必须在返回前完成数据导入;如果加载
|
|
588
|
+
* 失败,适配器负责回滚自身的分配。
|
|
589
|
+
*
|
|
590
|
+
* @param {FormatAdapter} adapter - 实现 load(allocator) 的适配器。
|
|
591
|
+
* @returns {number} 适配器返回的句柄。
|
|
592
|
+
* @throws {TypeError} 适配器未实现 load() 方法时。
|
|
593
|
+
* @throws {Error} 适配器拒绝所提供的基础设施时。
|
|
594
|
+
*/
|
|
595
|
+
loadData(adapter: FormatAdapter): number;
|
|
566
596
|
/**
|
|
567
597
|
* 防止对已借用的块进行修改操作。
|
|
568
598
|
*
|
|
@@ -572,7 +602,8 @@ export default class Balloc {
|
|
|
572
602
|
* @returns {void}
|
|
573
603
|
* @throws {Error} 如果块正通过 withView() 被借用。
|
|
574
604
|
* @private
|
|
575
|
-
|
|
605
|
+
* @deprecated
|
|
606
|
+
*/
|
|
576
607
|
private assertNotBorrowed;
|
|
577
608
|
/**
|
|
578
609
|
* 防止在存在任何借用片段时替换或重新映射 dataBus 的操作。
|