adapt_js / Exports / AdaptObjectLifetime

Class: AdaptObjectLifetime

Table of contents

Constructors

Methods

Constructors

constructor

new AdaptObjectLifetime()

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:97

Methods

Deposit

Deposit(object): void

Attach an object to the given lifetime object.

Example

AdaptEnvironment.InitializeAsync().then(() => {
     const lifetime = new AdaptObjectLifetime();
     const value = new AdaptValue(undefined, 5);
     lifetime.Deposit(value);

     lifetime.Finalize();
})

Parameters

Name Type Description
object AdaptObject The object to be attached to the lifetime object

Returns

void

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:115


Finalize

Finalize(): void

Destroy all the objects managed by the lifetime

Example

AdaptEnvironment.InitializeAsync().then(() => {
     const lifetime = new AdaptObjectLifetime();
     const value = new AdaptValue(lifetime, 5);
     const value1 = new AdaptValue(lifetime, 6);

     lifetime.Finalize(); // both value and value1 get destroyed by this call
})

Returns

void

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:153


Withdraw

Withdraw(object): boolean

Delete an object from the set of objects managed by the lifetime, so the object does not get deleted when the Finalized method is called.

Note: This method does not destroy the object.

Example

AdaptEnvironment.InitializeAsync().then(() => {
     const lifetime = new AdaptObjectLifetime();
     const value = new AdaptValue(lifetime, 5);
     lifetime.Withdraw(value);

     lifetime.Finalize(); // value is not destroyed
     value.Destroy();
})

Parameters

Name Type Description
object AdaptObject The object to delete from the lifetime

Returns

boolean

True if the object was deleted from the lifetime, otherwise false

Defined in

common/dist/memory_management/adapt_object_lifetime.d.ts:136