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

com.vmlens.trace.agent.bootstrap.interleave.MonitorState Maven / Gradle / Ivy

There is a newer version: 1.1.5
Show newest version
package com.vmlens.trace.agent.bootstrap.interleave;

import java.util.Arrays;

public class MonitorState {

	private int[] monitorArray;
	private int[] exclusiveLockArray;
	private int[] sharedLockArray;
	
	public MonitorState(int[] monitorArray, int[] exclusiveLockArray, int[] sharedLockArray) {
		super();
		this.monitorArray = monitorArray;
		this.exclusiveLockArray = exclusiveLockArray;
		this.sharedLockArray = sharedLockArray;
	}

	public boolean contains(MonitorState other) {
		
		for( int i : monitorArray )
		{
			for(int j : other.monitorArray )
			{
				if( i == j  )
				{
					return true;
				}
			}
		}
		
		
		for( int i : exclusiveLockArray )
		{
			for(int j : other.exclusiveLockArray )
			{
				if( i == j  )
				{
					return true;
				}
			}
			
			for(int j : other.sharedLockArray )
			{
				if( i == j  )
				{
					return true;
				}
			}
			
			
			
		}
		
		
		for( int i : sharedLockArray )
		{
			for(int j : other.exclusiveLockArray )
			{
				if( i == j  )
				{
					return true;
				}
			}
		}
		
		
		
		return false;
	}

	@Override
	public String toString() {
		return "MonitorState [monitorArray=" + Arrays.toString(monitorArray) + ", exclusiveLockArray="
				+ Arrays.toString(exclusiveLockArray) + ", sharedLockArray=" + Arrays.toString(sharedLockArray) + "]";
	}
	
	
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy