Modify structure member variable initialization operations

Describe:Add the initialization of timeReq_ to the constructor.

issue:https://gitee.com/openharmony/js_worker_module/issues/I556KJ?from=project-issue

Signed-off-by: yqhan <hanyuqing2@huawei.com>
This commit is contained in:
yqhan 2022-04-28 15:40:39 +08:00
parent 0f54d73c4f
commit bd31821245
2 changed files with 7 additions and 5 deletions

View File

@ -15,8 +15,6 @@
#include "base/compileruntime/js_worker_module/plugin/timer.h"
#include "base/compileruntime/js_worker_module/helper/napi_helper.h"
#include "base/compileruntime/js_worker_module/helper/object_helper.h"
#include "utils/log.h"
namespace CompilerRuntime::WorkerModule::Plugin {
@ -165,8 +163,6 @@ napi_value Timer::SetTimeoutInner(napi_env env, napi_callback_info cbinfo, bool
napi_ref callbackRef = Helper::NapiHelper::CreateReference(env, argv[0], 1);
TimerCallbackInfo* callbackInfo =
new TimerCallbackInfo(env, tId, timeout, callbackRef, repeat, callbackArgc, callbackArgv);
uv_loop_t* loop = Helper::NapiHelper::GetLibUV(env);
uv_timer_init(loop, &callbackInfo->timeReq_);
// 5. push callback info into timerTable
timerTable[tId] = callbackInfo;

View File

@ -18,6 +18,9 @@
#include <map>
#include <uv.h>
#include "base/compileruntime/js_worker_module/helper/napi_helper.h"
#include "base/compileruntime/js_worker_module/helper/object_helper.h"
#include "napi/native_api.h"
#include "napi/native_node_api.h"
@ -36,7 +39,10 @@ struct TimerCallbackInfo {
bool repeat, size_t argc, napi_ref* argv)
: env_(env), tId_(tId), timeout_(timeout), callback_(callback),
repeat_(repeat), argc_(argc), argv_(argv)
{}
{
uv_loop_t* loop = Helper::NapiHelper::GetLibUV(env_);
uv_timer_init(loop, &timeReq_);
}
~TimerCallbackInfo();
};