File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
src/fr/adrienbrault/idea/symfony2plugin/stubs/cache Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ package fr .adrienbrault .idea .symfony2plugin .stubs .cache ;
2+
3+ import fr .adrienbrault .idea .symfony2plugin .dic .ContainerService ;
4+ import java .util .HashMap ;
5+ import java .util .Map ;
6+
7+ public class ServiceBuilderTimeCache {
8+
9+ private boolean isInit = false ;
10+ private Boolean inWrite = false ;
11+ private Map <String , ContainerService > containerMap = new HashMap <String , ContainerService >();
12+ private final Object lock = new Object ();
13+
14+ synchronized public boolean isInitAndStart () {
15+
16+ if (this .isInit ) {
17+ return true ;
18+ }
19+
20+ this .isInit = true ;
21+
22+ return false ;
23+ }
24+
25+ public void startWrite () {
26+ this .inWrite = true ;
27+ }
28+
29+ public void endWrite (Map <String , ContainerService > foo ) {
30+ synchronized (lock ){
31+ containerMap .putAll (foo );
32+ inWrite = false ;
33+ lock .notify ();
34+ }
35+ }
36+
37+ public Map <String , ContainerService > getContainerMap () {
38+ synchronized (lock ){
39+ while (inWrite ) {
40+ try {
41+ lock .wait ();
42+ } catch (InterruptedException e ) {
43+ return this .containerMap ;
44+ }
45+ }
46+ }
47+ return this .containerMap ;
48+ }
49+
50+ }
You can’t perform that action at this time.
0 commit comments