General -> Workspace -> Refresh using native hooks or polling"是做什么的?-6ren"> General -> Workspace -> Refresh using native hooks or polling"是做什么的?-Eclipse 上有这个复选框: 首选项 -> 常规 -> 工作区 -> 使用 native Hook 或轮询刷新 Eclipse documentation说: If this option is -6ren">
gpt4 book ai didi

java - 在 Eclipse 上, "Preferences -> General -> Workspace -> Refresh using native hooks or polling"是做什么的?

转载 作者:搜寻专家 更新时间:2023-10-30 19:42:32 27 4
gpt4 key购买 nike

Eclipse 上有这个复选框:

首选项 -> 常规 -> 工作区 -> 使用 native Hook 或轮询刷新

Eclipse documentation说:

If this option is turned on then the workspace resources will be synchronized with their corresponding resources in the file system automatically using native refresh providers (on Windows) or a polling mechanism.

从文档和复选框描述中可以看出,Eclipse 使用某种操作系统 Hook 来获取有关文件更改的通知。而且似乎此功能是在 Windows 以外的操作系统上使用轮询模拟的。

我的问题是:

  1. 这真的是 Eclipse 正在做的事情吗?我想知道通过选中此选项是否会有一个线程不断检查文件系统。我的文件在外部发生变化,但一天大约 4 次,为了使这个功能对程序员来说看起来不错,轮询必须每分钟左右检查一次文件系统。
  2. 这真的只适用于 Windows 吗?如果我在 Linux 上使用 Eclipse,这是否一定意味着 Eclipse 将进入轮询模式?
  3. 最后,也是更重要的一点,如果 Eclipse 做到了,那么它是如何做到的? JNI?

最佳答案

是的,这确实是 Eclipse 正在做的事情。对于 Mac 或 Linux,它目前使用轮询。

有一个扩展点 org.eclipse.core.resources.refreshProviders 可以用来为每个平台提供刷新代码,人们已经为 Mac 和 Linux 编写了测试插件,但他们没有在产品中(参见 https://bugs.eclipse.org/bugs/show_bug.cgi?id=108697https://bugs.eclipse.org/bugs/show_bug.cgi?id=237344 )

来源是 org.eclipse.core.internal.refresh.MonitorManagerPollingMonitor 进行轮询刷新。

org.eclipse.core.internal.resources.refresh.win32.Win32RefreshProvider 通过 JNI 使用 native 方法进行 Windows 刷新(它位于仅限 Windows 的插件中)。

org.eclipse.core.internal.resources.refresh.win32.Win32MonitorWin32Natives 包含核心代码。

关于java - 在 Eclipse 上, "Preferences -> General -> Workspace -> Refresh using native hooks or polling"是做什么的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19951785/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com