File tree Expand file tree Collapse file tree 2 files changed +27
-19
lines changed
core/src/main/java/network/aika/elements/neurons Expand file tree Collapse file tree 2 files changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -109,35 +109,43 @@ public Model getModel() {
109109 return model ;
110110 }
111111
112- public synchronized void increaseRefCount (RefType rt ) {
113- refCount ++;
114- refCountByType [rt .ordinal ()]++;
115-
116- if (!isRegistered && refCount > 0 ) {
117- model .register (this );
118- isRegistered = true ;
112+ public void increaseRefCount (RefType rt ) {
113+ synchronized (refCountByType ) {
114+ refCount ++;
115+ refCountByType [rt .ordinal ()]++;
116+
117+ if (!isRegistered && refCount > 0 ) {
118+ model .register (this );
119+ isRegistered = true ;
120+ }
119121 }
120122 }
121123
122- public synchronized void decreaseRefCount (RefType rt ) {
123- refCount --;
124- refCountByType [rt .ordinal ()]--;
124+ public void decreaseRefCount (RefType rt ) {
125+ synchronized (refCountByType ) {
126+ refCount --;
127+ refCountByType [rt .ordinal ()]--;
125128
126- assert refCount >= 0 ;
127- assert refCountByType [rt .ordinal ()] >= 0 ;
129+ assert refCount >= 0 ;
130+ assert refCountByType [rt .ordinal ()] >= 0 ;
128131
129- if (isRegistered && refCount == 0 ) {
130- model .unregister (this );
131- isRegistered = false ;
132+ if (isRegistered && refCount == 0 ) {
133+ model .unregister (this );
134+ isRegistered = false ;
135+ }
132136 }
133137 }
134138
135- public synchronized int getRefCount () {
136- return refCount ;
139+ public int getRefCount () {
140+ synchronized (refCountByType ) {
141+ return refCount ;
142+ }
137143 }
138144
139145 public boolean isReferenced () {
140- return refCount > 0 ;
146+ synchronized (refCountByType ) {
147+ return refCount > 0 ;
148+ }
141149 }
142150
143151 public boolean isSuspended () {
Original file line number Diff line number Diff line change 7777
7878
7979 <properties >
80- <revision >2.0.9-rc27 </revision >
80+ <revision >2.0.9-rc28 </revision >
8181
8282 <project .build.sourceEncoding>UTF-8</project .build.sourceEncoding>
8383
You can’t perform that action at this time.
0 commit comments