Skip to content

AsyncScramWorker ​

Defines a class for asynchronous execution of SCRAM engine. More...

#include <AsyncScramWorker.h>

Inherits from Napi::AsyncWorker

Public Functions ​

Name
AsyncScramWorker(Napi::Function & callback, std::vector< std::string > args)<br>Constructor for ScramWorker.
~AsyncScramWorker() override =default<br>Virtual destructor for ScramWorker.
voidExecute() override<br>Executes the main logic of the worker.
voidOnOK() override<br>Callback method called upon successful execution.

Detailed Description ​

cpp
class AsyncScramWorker;

Defines a class for asynchronous execution of SCRAM engine.

This class inherits from Napi::AsyncWorker to perform tasks in a separate thread and notify upon completion. It's designed to execute SCRAM-related operations asynchronously in a Node.js environment.

Public Functions Documentation ​

function AsyncScramWorker ​

cpp
explicit AsyncScramWorker(
    Napi::Function & callback,
    std::vector< std::string > args
)

Constructor for ScramWorker.

Parameters:

  • callback A Napi::Function reference for asynchronous callback.
  • args A vector of command-line arguments for the SCRAM engine.

function ~AsyncScramWorker ​

cpp
~AsyncScramWorker() override =default

Virtual destructor for ScramWorker.

function Execute ​

cpp
void Execute() override

Executes the main logic of the worker.

This method contains the task to be performed in the background thread. It's called automatically by the Node.js event loop.

This method converts the command-line arguments to argc and argv format, parses the arguments, and runs the SCRAM analysis. Any exceptions are caught and recorded as errors.

function OnOK ​

cpp
void OnOK() override

Callback method called upon successful execution.

This method is invoked when the Execute method completes successfully. It's responsible for handling the results and invoking the JavaScript callback.

This method is invoked when the Execute method completes without errors. It calls the JavaScript callback function with a null argument, indicating successful completion.


Updated on 2025-12-19 at 21:56:46 +0000