在Eclipse中,“首选项->通用->工作区->使用本机钩子或轮询”做了什么?

时间:2023-01-24 23:02:53

There is this check box on Eclipse:

在Eclipse上有一个复选框:

Preferences -> General -> Workspace -> Refresh using native hooks or polling

首选项->通用->工作区-使用本机钩子或轮询刷新>

The Eclipse documentation says:

Eclipse文档说:

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.

如果打开此选项,那么将使用本机刷新提供程序(在Windows上)或轮询机制自动将工作区资源与文件系统中相应的资源同步。

From the documentation and the check box description suggest that there is some sort of OS hook that Eclipse uses to get notifications about file changes. And it seems that this feature is emulated on OSes other than Windows using polling.

从文档和复选框描述中可以看出,Eclipse使用某种OS钩子获得关于文件更改的通知。而且,这个特性似乎是在使用轮询的Windows以外的OSes上模拟的。

My questions are:

我的问题是:

  1. Is this really what Eclipse is doing? I want to know if by checking this option I will have a thread constantly checking the file system. My files change externally, but some 4 times a day, and to make this feature look fine for programmers a polling would have to check the file system once a minute or so.
  2. 这就是Eclipse正在做的事情吗?我想知道通过检查这个选项,是否会有一个线程不断地检查文件系统。我的文件是在外部修改的,但每天大约要修改4次,为了让这个特性对程序员来说更合适,轮询必须每分钟检查一次文件系统。
  3. Does that really work only on Windows? If I am using Eclipse on Linux, does that necessarily means Eclipse will go to polling mode?
  4. 这真的只适用于Windows吗?如果我在Linux上使用Eclipse,这是否意味着Eclipse将进入轮询模式?
  5. Finally, and more importantly, if Eclipse does that, then how does it do it? JNI?
  6. 最后,更重要的是,如果Eclipse做到了这一点,那么它是如何做到的呢?JNI吗?

3 个解决方案

#1


9  

Yes, this is really what Eclipse is doing. For Mac or Linux it currently uses polling.

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

There is an extension point org.eclipse.core.resources.refreshProviders that can be used to provide the refresh code for each platform and people have written test plugins for Mac and Linux but they are not in the product (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=108697 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=237344 )

有一个扩展点org. eclipsee .core.resources。可用于为每个平台提供刷新代码的refreshprovider,人们为Mac和Linux编写了测试插件,但它们不在产品中(见https://bugs.eclipse.org/bugs/show_bug.cgi?)id = 108697和https://bugs.eclipse.org/bugs/show_bug.cgi?id = 237344)

Source for this is org.eclipse.core.internal.refresh.MonitorManager, PollingMonitor does the polling refresh.

来源是org.eclipse.core.internal.refresh.MonitorManager, PollingMonitor执行轮询刷新。

org.eclipse.core.internal.resources.refresh.win32.Win32RefreshProvider does the Windows refresh using native methods via JNI (it is in a Windows only plugin).

win32. win32refreshprovider通过JNI使用本地方法刷新Windows(它是Windows only插件)。

org.eclipse.core.internal.resources.refresh.win32.Win32Monitor and Win32Natives contain the core code.

org. eclipsee .core.internal.resources.refresh.win32. win32monitor和win32native包含核心代码。

#2


4  

I have found out that the option "Refresh using native hooks or polling" was to the old way of doing this:

我发现“使用本机钩子或轮询进行刷新”的选项是按照以前的方式进行的:

Previous Eclipse versions relied on native refresh providers (on Windows) or a polling mechanism to keep the workspace synchronized with the underlying filesystem. This capability can be still enabled by selecting Refresh using native hooks or polling on Opens the preference page Preferences > General > Workspace.

以前的Eclipse版本依赖于本地刷新提供程序(在Windows上)或轮询机制来保持与底层文件系统的工作空间同步。通过使用本机钩子选择Refresh或在打开首选项页面首选项>常规>工作区上轮询,仍然可以启用此功能。

Now a new lightweight mechanism is available. Files discovered to be out-of-sync by the workspace, for example while accessing the file content by an editor, will be automatically asynchronously refreshed. If you want to refresh files this way, go to Opens the preference page Preferences > General > Workspace and select Refresh on access.

现在有了一种新的轻量级机制。在工作空间中发现不同步的文件,例如通过编辑器访问文件内容时,将自动异步刷新。如果您希望以这种方式刷新文件,请转到打开首选项页面首选项>常规>工作区,并在访问时选择refresh。

From now on I'll go only with Refresh on access.

从现在开始,我将只访问Refresh。

#3


0  

"Refresh using native hooks or polling" can solve the problem about project building is not updated when files are edited using external editors. problem details

“使用本机钩子或轮询刷新”可以解决使用外部编辑器编辑文件时不更新项目构建的问题。问题的细节

#1


9  

Yes, this is really what Eclipse is doing. For Mac or Linux it currently uses polling.

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

There is an extension point org.eclipse.core.resources.refreshProviders that can be used to provide the refresh code for each platform and people have written test plugins for Mac and Linux but they are not in the product (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=108697 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=237344 )

有一个扩展点org. eclipsee .core.resources。可用于为每个平台提供刷新代码的refreshprovider,人们为Mac和Linux编写了测试插件,但它们不在产品中(见https://bugs.eclipse.org/bugs/show_bug.cgi?)id = 108697和https://bugs.eclipse.org/bugs/show_bug.cgi?id = 237344)

Source for this is org.eclipse.core.internal.refresh.MonitorManager, PollingMonitor does the polling refresh.

来源是org.eclipse.core.internal.refresh.MonitorManager, PollingMonitor执行轮询刷新。

org.eclipse.core.internal.resources.refresh.win32.Win32RefreshProvider does the Windows refresh using native methods via JNI (it is in a Windows only plugin).

win32. win32refreshprovider通过JNI使用本地方法刷新Windows(它是Windows only插件)。

org.eclipse.core.internal.resources.refresh.win32.Win32Monitor and Win32Natives contain the core code.

org. eclipsee .core.internal.resources.refresh.win32. win32monitor和win32native包含核心代码。

#2


4  

I have found out that the option "Refresh using native hooks or polling" was to the old way of doing this:

我发现“使用本机钩子或轮询进行刷新”的选项是按照以前的方式进行的:

Previous Eclipse versions relied on native refresh providers (on Windows) or a polling mechanism to keep the workspace synchronized with the underlying filesystem. This capability can be still enabled by selecting Refresh using native hooks or polling on Opens the preference page Preferences > General > Workspace.

以前的Eclipse版本依赖于本地刷新提供程序(在Windows上)或轮询机制来保持与底层文件系统的工作空间同步。通过使用本机钩子选择Refresh或在打开首选项页面首选项>常规>工作区上轮询,仍然可以启用此功能。

Now a new lightweight mechanism is available. Files discovered to be out-of-sync by the workspace, for example while accessing the file content by an editor, will be automatically asynchronously refreshed. If you want to refresh files this way, go to Opens the preference page Preferences > General > Workspace and select Refresh on access.

现在有了一种新的轻量级机制。在工作空间中发现不同步的文件,例如通过编辑器访问文件内容时,将自动异步刷新。如果您希望以这种方式刷新文件,请转到打开首选项页面首选项>常规>工作区,并在访问时选择refresh。

From now on I'll go only with Refresh on access.

从现在开始,我将只访问Refresh。

#3


0  

"Refresh using native hooks or polling" can solve the problem about project building is not updated when files are edited using external editors. problem details

“使用本机钩子或轮询刷新”可以解决使用外部编辑器编辑文件时不更新项目构建的问题。问题的细节