Skip to content

Commit

Permalink
Merge pull request #18 from CST-Group/improve-disconnected-codelet-me…
Browse files Browse the repository at this point in the history
…ssage

Improving the disconnected Codelet message to cite Codelet's name
  • Loading branch information
andre-paraense authored Nov 9, 2020
2 parents a7955ed + 232df41 commit c3ae8f3
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "CST is the Cognitive Systems Toolkit, a toolkit for the construct

sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '0.6.0'
version = '0.6.1'

repositories {
flatDir {
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/br/unicamp/cst/core/entities/Codelet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import br.unicamp.cst.core.exceptions.CodeletActivationBoundsException;
import br.unicamp.cst.core.exceptions.CodeletThresholdBoundsException;
import br.unicamp.cst.core.exceptions.MemoryObjectNotFoundException;
import br.unicamp.cst.util.ExecutionTimeWriter;
import br.unicamp.cst.util.ProfileInfo;

Expand Down Expand Up @@ -760,8 +761,8 @@ public synchronized void run() {
if (activation >= threshold)
proc();
} else {
System.out.println("This codelet thread could not find a memory object it needs (Class):"
+ this.getClass().getCanonicalName());
throw new MemoryObjectNotFoundException("This Codelet could not find a memory object it needs: "
+ Codelet.this.name);
}

enable_count = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
*
*/
package br.unicamp.cst.core.exceptions;

/**
* This class represents a Java exception to be thrown when the access memory object
* method is not capable of finding the corresponding memory object
*
* @author andre
*
*/
public class MemoryObjectNotFoundException extends Exception {

/**
*
*/
private static final long serialVersionUID = -6845401281653737754L;

/**
*
*/
public MemoryObjectNotFoundException() {
}

/**
* @param message
*/
public MemoryObjectNotFoundException(String message) {
super(message);
}

/**
* @param cause
*/
public MemoryObjectNotFoundException(Throwable cause) {
super(cause);
}

/**
* @param message
* @param cause
*/
public MemoryObjectNotFoundException(String message, Throwable cause) {
super(message, cause);
}

/**
* @param message
* @param cause
* @param enableSuppression
* @param writableStackTrace
*/
public MemoryObjectNotFoundException(String message, Throwable cause, boolean enableSuppression,
boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
*
*/
package br.unicamp.cst.core.entities;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

/**
* @author andre
*
*/
public class DisconnectedCodeletTest {

@Test
public void testDisconnectedCodelet() {

Codelet disconnectedCodelet = new Codelet() {

@Override
public void accessMemoryObjects() {
}

@Override
public void proc() {

}

@Override
public void calculateActivation() {

}
};
disconnectedCodelet.setName("Disconnected Codelet");
disconnectedCodelet.start();

try {
disconnectedCodelet.getInput("TYPE", 0);
}catch(Exception e) {
assertEquals(e.getMessage(), "This Codelet could not find a memory object it needs: Disconnected Codelet");
}
}

}

0 comments on commit c3ae8f3

Please sign in to comment.