All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.model.Resource Maven / Gradle / Ivy

package hudson.model;

/**
 * Represents things that {@link Queue.Executable} uses while running.
 *
 * 

* This is used in {@link Queue} to support basic mutual exclusion/locks. If two * {@link Queue.Task}s require the same {@link Resource}, they will not * be run at the same time. * *

* Resources are compared by using their {@link #displayName names}, and * need not have the "same object" semantics. * * @since 1.121 */ public final class Resource { /** * Human-readable name of this resource. * Used for rendering HTML. */ public final String displayName; /** * Parent resource. * *

* A child resource is considered a part of the parent resource, * so acquiring the parent resource always imply acquiring all * the child resources. */ public final Resource parent; /** * Maximum number of concurrent write. */ public final int numConcurrentWrite; public Resource(Resource parent, String displayName) { this(parent,displayName,1); } /** * @since 1.155 */ public Resource(Resource parent, String displayName, int numConcurrentWrite) { if(numConcurrentWrite<1) throw new IllegalArgumentException(); this.parent = parent; this.displayName = displayName; this.numConcurrentWrite = numConcurrentWrite; } public Resource(String displayName) { this(null,displayName); } /** * Checks the resource collision. * * @param count * If we are testing W/W conflict, total # of write counts. * For R/W conflict test, this value should be set to {@link Integer#MAX_VALUE}. */ public boolean isCollidingWith(Resource that, int count) { assert that!=null; for(Resource r=that; r!=null; r=r.parent) if(this.equals(r) && r.numConcurrentWrite





© 2015 - 2025 Weber Informatics LLC | Privacy Policy