OR
one queue was emptied.
- Author:
- bill
|
Constructor Summary |
MergeSortPipe(int numberOfworkers)
constructor |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MergeSortPipe
public MergeSortPipe(int numberOfworkers)
- constructor
- Parameters:
numberOfworkers - - the number of workers
setInActive
public void setInActive(int workerID)
- sets the workerID worker as inactive
- Parameters:
workerID -
isActive
public boolean isActive(int workerID)
- returns the state of the workerID
- Parameters:
workerID -
- Returns:
- true if workerID is active / false otherwise
getResultsRetrieved
public long getResultsRetrieved()
- gets the sum of the results retrieved
- Returns:
- resultsRetrieved
setResultsRetrieved
public void setResultsRetrieved(long resultsRetrieved)
- sets the resultsRetrieved
- Parameters:
resultsRetrieved -
getResultsSent
public long getResultsSent()
getGetUntil
public long getGetUntil()
- gets the sum of the results requested by the client,
until now
- Returns:
- getUntil
setGetUntil
public void setGetUntil(long getUntil)
- sets the number of results requested by the client
- Parameters:
getUntil -
add
public void add(int workerID,
ArrayList<MergeSortElement> elements)
- Adds a new elements' array in the queue
- Parameters:
workerID - - the ID of the owrker that adds the elementelements - - the elements to be added in the queue
getNext
public MergeSortElement getNext()
add
public void add(int workerID,
MergeSortElement element)
- Adds a new element in the queue
- Parameters:
workerID - - the ID of the owrker that adds the elementelement - - the element to be added in the queue
areAllQueuesNonEmpty
public boolean areAllQueuesNonEmpty()
- checks if all the queues, of the active workers,
have at least one element
- Returns:
- true if yes / false otherwise
isAnyWorkerLeft
public boolean isAnyWorkerLeft()
- checks if there is any worker left
- Returns:
- true if yes / false otherwise
canWorkerPause
public boolean canWorkerPause(int workerID)
- checks if a specific worker can sleep
- Parameters:
workerID - - the ID of the worker
- Returns:
- true if yes / false otherwise
canMergeSorterPause
public boolean canMergeSorterPause()
- checks if a MergeSorter can pause and let the
workers do the processing, until there is enough
data to do merge sorting, or there are more results
than the results requested by the client, or there
is no worker left
- Returns:
- true if yes / false otherwise
sendMergerNotification
public boolean sendMergerNotification()
- checks if a MergeSorter must receive a notification.
If we are in a state that the MergeSorter should not
be paused then a notification must be sent.
- Returns:
- true if yes / false otherwise
sendWorkersNotification
public boolean sendWorkersNotification()
- checks if workers must receive notifications. If there
is at least one active queue that is empty or the results
retrieved are less than the results requested by the
client.
- Returns:
- true if yes / false otherwise
setStop
public void setStop()
- raises the stop flag
isStoped
public boolean isStoped()
- returns the stop flag
- Returns:
- the stop flag
Copyright © 2013. All Rights Reserved.