Skip to content

Commit

Permalink
[unreal]除了io之外,libuv还有其它事件要处理,所以每100毫秒调用一次uvrun(electron是除了io外,主循环也有调用),
Browse files Browse the repository at this point in the history
  • Loading branch information
chexiongsheng committed Dec 31, 2021
1 parent b53a53f commit 5254211
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,12 @@ void FJsEnvImpl::UvRunOnce()
void FJsEnvImpl::PollEvents()
{
#if PLATFORM_WINDOWS
DWORD bytes, timeout;
DWORD bytes;
DWORD timeout = uv_backend_timeout(&NodeUVLoop);
ULONG_PTR key;
OVERLAPPED* overlapped;

timeout = uv_backend_timeout(&NodeUVLoop);
timeout = timeout > 100 ? 100 : timeout;

GetQueuedCompletionStatus(NodeUVLoop.iocp, &bytes, &key, &overlapped, timeout);

Expand All @@ -192,6 +193,7 @@ void FJsEnvImpl::PollEvents()
PostQueuedCompletionStatus(NodeUVLoop.iocp, bytes, key, overlapped);
#elif PLATFORM_LINUX
int timeout = uv_backend_timeout(&NodeUVLoop);
timeout = timeout > 100 ? 100 : timeout;

// Wait for new libuv events.
int r;
Expand All @@ -202,6 +204,7 @@ void FJsEnvImpl::PollEvents()
#elif PLATFORM_MAC
struct timeval tv;
int timeout = uv_backend_timeout(&NodeUVLoop);
timeout = timeout > 100 ? 100 : timeout;
if (timeout != -1) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
Expand Down

0 comments on commit 5254211

Please sign in to comment.