44import java .util .HashSet ;
55import java .nio .ByteBuffer ;
66import java .nio .ByteOrder ;
7- import java .util .concurrent .ArrayBlockingQueue ;
8- import java .util .concurrent .BlockingQueue ;
97import org .jlab .clara .base .ClaraUtil ;
108import org .jlab .clara .engine .Engine ;
119import org .jlab .clara .engine .EngineData ;
1210import org .jlab .clara .engine .EngineDataType ;
1311import org .jlab .clara .engine .EngineStatus ;
1412import org .jlab .detector .decode .CLASDecoder ;
13+ import org .jlab .detector .decode .CLASDecoderPool ;
1514import org .jlab .io .evio .EvioDataEvent ;
1615import org .jlab .io .hipo .HipoDataEvent ;
1716import org .jlab .jnp .hipo4 .data .SchemaFactory ;
@@ -28,8 +27,7 @@ public class DecoderEngine implements Engine {
2827 Clas12Types .EVIO ,Clas12Types .HIPO ,EngineDataType .JSON ,EngineDataType .STRING );
2928
3029 SchemaFactory schema ;
31- BlockingQueue <CLASDecoder > pool ;
32- int constantsShared = 64 ;
30+ CLASDecoderPool pool ;
3331
3432 public DecoderEngine () {
3533 schema = new SchemaFactory ();
@@ -58,21 +56,9 @@ public void destroy() {}
5856 @ Override
5957 public EngineData configure (EngineData ed ) {
6058 JSONObject json = new JSONObject (ed .getData ());
61- pool = new ArrayBlockingQueue <>(POOL_SIZE );
62- CLASDecoder d0 = null ;
63- for (int i =0 ; i <POOL_SIZE ; i ++) {
64- CLASDecoder d ;
65- if (i % constantsShared == 0 ) {
66- d0 = new CLASDecoder ();
67- if (json .has ("variation" )) d0 .setVariation (json .getString ("variation" ));
68- if (json .has ("timestamp" )) d0 .setVariation (json .getString ("timestamp" ));
69- d = d0 ;
70- }
71- else {
72- d = new CLASDecoder (d0 );
73- }
74- pool .add (d );
75- }
59+ pool = new CLASDecoderPool (POOL_SIZE ,
60+ json .optString ("variation" ,"default" ),
61+ json .optString ("timestamp" ,null ));
7662 return ed ;
7763 }
7864
0 commit comments