You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2008/07/10 14:25:08 UTC
svn commit: r675545 -
/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java
Author: seelmann
Date: Thu Jul 10 05:25:08 2008
New Revision: 675545
URL: http://svn.apache.org/viewvc?rev=675545&view=rev
Log:
Fixed code if a job should be scheduled
Modified:
directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java
Modified: directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java?rev=675545&r1=675544&r2=675545&view=diff
==============================================================================
--- directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java (original)
+++ directory/studio/trunk/connection-core/src/main/java/org/apache/directory/studio/connection/core/jobs/StudioConnectionJob.java Thu Jul 10 05:25:08 2008
@@ -215,48 +215,41 @@
/**
- * @see org.eclipse.core.runtime.jobs.Job#shouldSchedule()
+ * {@inheritDoc}
*/
public boolean shouldSchedule()
{
+ // We don't schedule a job if the same type of runnable should run
+ // that works on the same entry as the current runnable.
+
Object[] myLockedObjects = runnable.getLockedObjects();
String[] myLockedObjectsIdentifiers = getLockIdentifiers( myLockedObjects );
- // TODO: read, write
-
Job[] jobs = getJobManager().find( null );
for ( int i = 0; i < jobs.length; i++ )
{
Job job = jobs[i];
-
- // if(job instanceof AbstractEclipseJob) {
- if ( job.getClass() == this.getClass() && job != this )
+ if ( job instanceof StudioConnectionJob )
{
StudioConnectionJob otherJob = ( StudioConnectionJob ) job;
- Object[] otherLockedObjects = otherJob.runnable.getLockedObjects();
- String[] otherLockedObjectIdentifiers = getLockIdentifiers( otherLockedObjects );
-
- for ( int j = 0; j < otherLockedObjectIdentifiers.length; j++ )
+ if ( this.runnable.getClass() == otherJob.runnable.getClass() && this.runnable != otherJob.runnable )
{
- String other = otherLockedObjectIdentifiers[j];
- for ( int k = 0; k < myLockedObjectsIdentifiers.length; k++ )
- {
- String my = myLockedObjectsIdentifiers[k];
+ Object[] otherLockedObjects = otherJob.runnable.getLockedObjects();
+ String[] otherLockedObjectIdentifiers = getLockIdentifiers( otherLockedObjects );
- //System.out.print( "other:" + other + ", my: " + my );
- if ( other.startsWith( my ) || my.startsWith( other ) )
- {
- //System.out.println( ", shouldSchedule() = " + false );
- return false;
- }
- else
+ for ( int j = 0; j < otherLockedObjectIdentifiers.length; j++ )
+ {
+ String other = otherLockedObjectIdentifiers[j];
+ for ( int k = 0; k < myLockedObjectsIdentifiers.length; k++ )
{
- //System.out.println();
+ String my = myLockedObjectsIdentifiers[k];
+ if ( other.startsWith( my ) || my.startsWith( other ) )
+ {
+ return false;
+ }
}
-
}
}
-
}
}
return super.shouldSchedule();