mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-04-26 23:42:15 +00:00
readme [ci skip]
This commit is contained in:
parent
e36722f2e6
commit
41abc0166c
@ -17,5 +17,5 @@ Common
|
|||||||
Optional
|
Optional
|
||||||
--------
|
--------
|
||||||
|
|
||||||
* **__mem_reset**(ref: `usize`, parentRef: `usize`)<br />
|
* **__mem_reset**(ref: `usize`, parentRef: `usize`): `void`<br />
|
||||||
Resets dynamic memory to its initial state. Used by the arena allocator.
|
Resets dynamic memory to its initial state. Used by the arena allocator.
|
||||||
|
@ -6,31 +6,31 @@ A garbage collector for AssemblyScript must implement the following common and e
|
|||||||
Common
|
Common
|
||||||
------
|
------
|
||||||
|
|
||||||
* **__ref_collect**()<br />
|
* **__ref_collect**(): `void`<br />
|
||||||
Triggers a full garbage collection cycle. Also indicates the presence of a GC.
|
Triggers a full garbage collection cycle. Also indicates the presence of a GC.
|
||||||
|
|
||||||
Tracing
|
Tracing
|
||||||
-------
|
-------
|
||||||
|
|
||||||
* **__ref_register**(ref: `usize`)<br />
|
* **__ref_register**(ref: `usize`): `void`<br />
|
||||||
Sets up a new reference.
|
Sets up a new reference.
|
||||||
|
|
||||||
* **__ref_link**(ref: `usize`, parentRef: `usize`)<br />
|
* **__ref_link**(ref: `usize`, parentRef: `usize`): `void`<br />
|
||||||
Links a reference to a parent that is now referencing it.
|
Links a reference to a parent that is now referencing it.
|
||||||
|
|
||||||
* **__ref_unlink**(ref: `usize`, parentRef: `usize`)<br />
|
* **__ref_unlink**(ref: `usize`, parentRef: `usize`): `void`<br />
|
||||||
Unlinks a reference from a parent that was referencing it.
|
Unlinks a reference from a parent that was referencing it.
|
||||||
|
|
||||||
Reference counting
|
Reference counting
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
* **__ref_register**(ref: `usize`)<br />
|
* **__ref_register**(ref: `usize`): `void`<br />
|
||||||
Sets up a new reference. Implementation is optional for reference counting GCs.
|
Sets up a new reference. Implementation is optional for reference counting GCs.
|
||||||
|
|
||||||
* **__ref_retain**(ref: `usize`)<br />
|
* **__ref_retain**(ref: `usize`): `void`<br />
|
||||||
Retains a reference, usually incrementing RC.
|
Retains a reference, usually incrementing RC.
|
||||||
|
|
||||||
* **__ref_release**(ref: `usize`)<br />
|
* **__ref_release**(ref: `usize`): `void`<br />
|
||||||
Releases a reference, usually decrementing RC.
|
Releases a reference, usually decrementing RC.
|
||||||
|
|
||||||
Typical patterns
|
Typical patterns
|
||||||
@ -79,10 +79,10 @@ if (ref !== oldRef) {
|
|||||||
} else assert(false);
|
} else assert(false);
|
||||||
} else {
|
} else {
|
||||||
if (isDefined(__ref_link)) {
|
if (isDefined(__ref_link)) {
|
||||||
__ref_unlink(oldRef, parentRef);
|
if (oldRef) __ref_unlink(oldRef, parentRef); // *
|
||||||
__ref_link(ref, parentRef);
|
__ref_link(ref, parentRef);
|
||||||
} else if (isDefined(__ref_retain)) {
|
} else if (isDefined(__ref_retain)) {
|
||||||
__ref_release(oldRef);
|
if (oldRef) __ref_release(oldRef); // *
|
||||||
__ref_retain(ref);
|
__ref_retain(ref);
|
||||||
} else assert(false);
|
} else assert(false);
|
||||||
}
|
}
|
||||||
@ -105,4 +105,4 @@ if (isNullable<T>()) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that some data structures may contain `null` values even though the value type isn't nullable. May be the case when appending a new element to an array for example.
|
(*) Note that some data structures may contain `null` values even though the value type isn't nullable. May be the case when appending a new element to an array for example.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user