提交 f68ab9ca 编写于 作者: K kohsuke

the poll method already handles necessary mutual exclusions

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@27301 71c3de6d-444a-0410-be80-ed276b4c234a
上级 e605d071
......@@ -1053,9 +1053,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
/**
* Checks if there's any update in SCM, and returns true if any is found.
*
* <p>
* The caller is responsible for coordinating the mutual exclusion between
* a build and polling, as both touches the workspace.
* @deprecated as of 1.346
* Use {@link #poll(TaskListener)} instead.
*/
public boolean pollSCMChanges( TaskListener listener ) {
return poll(listener).hasChanges();
......@@ -1065,8 +1064,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
* Checks if there's any update in SCM, and returns true if any is found.
*
* <p>
* The caller is responsible for coordinating the mutual exclusion between
* a build and polling, as both touches the workspace.
* The implementation is responsible for ensuring mutual exclusion between polling and builds
* if necessary.
*
* @since 1.345
*/
......@@ -1123,7 +1122,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return BUILD_NOW;
} else {
WorkspaceList l = lb.getBuiltOn().toComputer().getWorkspaceList();
// if doing non-concurrent build, acquite a workspace in a way that causes builds to block for this workspace.
// if doing non-concurrent build, acquire a workspace in a way that causes builds to block for this workspace.
// this prevents multiple workspaces of the same job --- the behavior of Hudson < 1.319.
//
// OTOH, if a concurrent build is chosen, the user is willing to create a multiple workspace,
......
......@@ -23,6 +23,7 @@
*/
package hudson.model;
import hudson.scm.PollingResult;
import hudson.scm.SCM;
import hudson.triggers.SCMTrigger;
......@@ -54,9 +55,21 @@ public interface SCMedItem extends BuildableItem {
/**
* Checks if there's any update in SCM, and returns true if any is found.
*
* <p>
* The caller is responsible for coordinating the mutual exclusion between
* a build and polling, as both touches the workspace.
* @deprecated as of 1.346
* Use {@link #poll(TaskListener)} instead.
*/
boolean pollSCMChanges( TaskListener listener );
/**
* Checks if there's any update in SCM, and returns true if any is found.
*
* <p>
* The implementation is responsible for ensuring mutual exclusion between polling and builds
* if necessary.
*
* @return never null.
*
* @since 1.345
*/
public PollingResult poll( TaskListener listener );
}
......@@ -316,7 +316,7 @@ public class SCMTrigger extends Trigger<SCMedItem> {
PrintStream logger = listener.getLogger();
long start = System.currentTimeMillis();
logger.println("Started on "+ DateFormat.getDateTimeInstance().format(new Date()));
boolean result = job.pollSCMChanges(listener);
boolean result = job.poll(listener).hasChanges();
logger.println("Done. Took "+ Util.getTimeSpanString(System.currentTimeMillis()-start));
if(result)
logger.println("Changes found");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册