[DEBUG] correct synchronization of Context
This commit is contained in:
parent
de79013881
commit
31dae9d4e3
@ -44,9 +44,11 @@ public class ResourceManager {
|
|||||||
* This is to inform the resources manager that we have no more openGl context ...
|
* This is to inform the resources manager that we have no more openGl context ...
|
||||||
*/
|
*/
|
||||||
public synchronized void contextHasBeenDestroyed() {
|
public synchronized void contextHasBeenDestroyed() {
|
||||||
for (final Resource it : this.resourceList) {
|
synchronized (this.resourceList) {
|
||||||
if (it.getCount() > 0) {
|
for (final Resource it : this.resourceList) {
|
||||||
it.removeContextToLate();
|
if (it.getCount() > 0) {
|
||||||
|
it.removeContextToLate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// no context preent ...
|
// no context preent ...
|
||||||
@ -59,33 +61,40 @@ public class ResourceManager {
|
|||||||
public synchronized void display() {
|
public synchronized void display() {
|
||||||
Log.info("Resources loaded : ");
|
Log.info("Resources loaded : ");
|
||||||
// remove all resources ...
|
// remove all resources ...
|
||||||
for (final Resource it : this.resourceList) {
|
|
||||||
Log.info(" [" + it.getId() + "]" + it.getClass().getCanonicalName() + "='" + it.getName() + "' " + it.getCount() + " elements");
|
synchronized (this.resourceList) {
|
||||||
|
for (final Resource it : this.resourceList) {
|
||||||
|
Log.info(" [" + it.getId() + "]" + it.getClass().getCanonicalName() + "='" + it.getName() + "' " + it.getCount() + " elements");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Log.info("Resources ---");
|
Log.info("Resources ---");
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void localAdd(final Resource object) {
|
public synchronized void localAdd(final Resource object) {
|
||||||
// add at the end if no slot is free
|
// add at the end if no slot is free
|
||||||
this.resourceList.add(object);
|
synchronized (this.resourceList) {
|
||||||
|
this.resourceList.add(object);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal API to extent eResources in extern Soft
|
// internal API to extent eResources in extern Soft
|
||||||
public synchronized Resource localKeep(final String filename) {
|
public synchronized Resource localKeep(final String filename) {
|
||||||
Log.verbose("KEEP (DEFAULT) : file : '" + filename + "' in " + this.resourceList.size() + " resources");
|
synchronized (this.resourceList) {
|
||||||
for (final Resource it : this.resourceList) {
|
Log.verbose("KEEP (DEFAULT) : file : '" + filename + "' in " + this.resourceList.size() + " resources");
|
||||||
if (it == null) {
|
for (final Resource it : this.resourceList) {
|
||||||
continue;
|
if (it == null) {
|
||||||
}
|
continue;
|
||||||
if (it.getName() == null) {
|
}
|
||||||
continue;
|
if (it.getName() == null) {
|
||||||
}
|
continue;
|
||||||
//Log.verbose("compare : " + filename + " ==???== " + it.getName());
|
}
|
||||||
if (it.getName().contentEquals(Resource.NO_NAME_RESOURCE)) {
|
//Log.verbose("compare : " + filename + " ==???== " + it.getName());
|
||||||
continue;
|
if (it.getName().contentEquals(Resource.NO_NAME_RESOURCE)) {
|
||||||
}
|
continue;
|
||||||
if (it.getName().contentEquals(filename)) {
|
}
|
||||||
return it;
|
if (it.getName().contentEquals(filename)) {
|
||||||
|
return it;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -103,13 +112,15 @@ public class ResourceManager {
|
|||||||
public synchronized void reLoadResources() {
|
public synchronized void reLoadResources() {
|
||||||
Log.info("------------- Resources re-loaded -------------");
|
Log.info("------------- Resources re-loaded -------------");
|
||||||
// remove all resources ...
|
// remove all resources ...
|
||||||
for (long jjj = 0; jjj < MAX_RESOURCE_LEVEL; jjj++) {
|
for (long jjj = 0; jjj < ResourceManager.MAX_RESOURCE_LEVEL; jjj++) {
|
||||||
Log.info(" Reload level : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
|
Log.info(" Reload level : " + jjj + "/" + (ResourceManager.MAX_RESOURCE_LEVEL - 1));
|
||||||
for (final Resource it : this.resourceList) {
|
synchronized (this.resourceList) {
|
||||||
if (jjj == it.getResourceLevel()) {
|
for (final Resource it : this.resourceList) {
|
||||||
if (it.getCount() > 0) {
|
if (jjj == it.getResourceLevel()) {
|
||||||
it.reload();
|
if (it.getCount() > 0) {
|
||||||
Log.info(" [" + it.getId() + "]=" + it.getClass().getCanonicalName());
|
it.reload();
|
||||||
|
Log.info(" [" + it.getId() + "]=" + it.getClass().getCanonicalName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -131,10 +142,12 @@ public class ResourceManager {
|
|||||||
display();
|
display();
|
||||||
this.resourceListToUpdate.clear();
|
this.resourceListToUpdate.clear();
|
||||||
// remove all resources ...
|
// remove all resources ...
|
||||||
for (final Resource it : this.resourceList) {
|
synchronized (this.resourceList) {
|
||||||
Log.warning("Find a resource that is not removed : [" + it.getId() + "]" + "='" + it.getName() + "' " + it.getCount() + " elements");
|
for (final Resource it : this.resourceList) {
|
||||||
|
Log.warning("Find a resource that is not removed : [" + it.getId() + "]" + "='" + it.getName() + "' " + it.getCount() + " elements");
|
||||||
|
}
|
||||||
|
this.resourceList.clear();
|
||||||
}
|
}
|
||||||
this.resourceList.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,8 +185,8 @@ public class ResourceManager {
|
|||||||
}
|
}
|
||||||
synchronized (this.resourceList) {
|
synchronized (this.resourceList) {
|
||||||
if (this.resourceList.size() != 0) {
|
if (this.resourceList.size() != 0) {
|
||||||
for (long jjj = 0; jjj < MAX_RESOURCE_LEVEL; jjj++) {
|
for (long jjj = 0; jjj < ResourceManager.MAX_RESOURCE_LEVEL; jjj++) {
|
||||||
Log.verbose(" updateContext level (D) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
|
Log.verbose(" updateContext level (D) : " + jjj + "/" + (ResourceManager.MAX_RESOURCE_LEVEL - 1));
|
||||||
for (final Resource it : this.resourceList) {
|
for (final Resource it : this.resourceList) {
|
||||||
if (jjj == it.getResourceLevel()) {
|
if (jjj == it.getResourceLevel()) {
|
||||||
//Log.debug("Update context named : " + lresourceList[iii].getName());
|
//Log.debug("Update context named : " + lresourceList[iii].getName());
|
||||||
@ -195,8 +208,8 @@ public class ResourceManager {
|
|||||||
this.resourceListToUpdate = new ArrayList<>();
|
this.resourceListToUpdate = new ArrayList<>();
|
||||||
}
|
}
|
||||||
if (resourceListToUpdate.size() != 0) {
|
if (resourceListToUpdate.size() != 0) {
|
||||||
for (long jjj = 0; jjj < MAX_RESOURCE_LEVEL; jjj++) {
|
for (long jjj = 0; jjj < ResourceManager.MAX_RESOURCE_LEVEL; jjj++) {
|
||||||
Log.verbose(" updateContext level (U) : " + jjj + "/" + (MAX_RESOURCE_LEVEL - 1));
|
Log.verbose(" updateContext level (U) : " + jjj + "/" + (ResourceManager.MAX_RESOURCE_LEVEL - 1));
|
||||||
for (final Resource it : resourceListToUpdate) {
|
for (final Resource it : resourceListToUpdate) {
|
||||||
if (jjj == it.getResourceLevel()) {
|
if (jjj == it.getResourceLevel()) {
|
||||||
if (!it.updateContext()) {
|
if (!it.updateContext()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user