Skip to content
This repository was archived by the owner on May 15, 2023. It is now read-only.
This repository was archived by the owner on May 15, 2023. It is now read-only.

core: Runtime allocator & Event dispatcher #5

@Cassolette

Description

@Cassolette

This component is very important to the core operation of BT (or any mousebase-based modules). Similar to the Event Loop of NodeJS, this library is responsible for:

  • Ensuring runtime usage stays in a healthy range
  • Events are postponed when free runtime is running low
  • Async operations (core: Promise + Async / await library #4) and/or events are run in an unproblematic manner

For the last point, consider the following snippet:

btp:setLanguage(language)

-- Because of the synchronous manner in which the above function is executed and this event is emitted,
-- the below will not run in time
btp:once('languageChanged', function()
      btp:tlbChatMsg(LOCBUILDER_CHANGED_LANG)
end)

By using the flow in which Node handles sequencing, we are able to queue the emission of languageChanged after the current task is completed, as a microTask (see process.nextTick).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions