protected void initializeTaskDone(Set<TaskImageContainer> tasks,Optional<Runnable> runnableWhenDone){
  Set<CaptureSession> sessionSet=new HashSet<>();
  Map<CaptureSession,Integer> sessionTaskCount=new HashMap<>();
  for (  TaskImageContainer task : tasks) {
    sessionSet.add(task.mSession);
    Integer currentCount=sessionTaskCount.get(task.mSession);
    if (currentCount == null) {
      sessionTaskCount.put(task.mSession,1);
    }
 else {
      sessionTaskCount.put(task.mSession,currentCount + 1);
    }
  }
synchronized (mShadowTaskMap) {
    for (    CaptureSession captureSession : sessionSet) {
      BlockSignalProtocol protocol=new BlockSignalProtocol();
      protocol.setCount(sessionTaskCount.get(captureSession));
      final ImageShadowTask shadowTask;
      shadowTask=new ImageShadowTask(protocol,captureSession,runnableWhenDone);
      mShadowTaskMap.put(captureSession,shadowTask);
      mProcessingTaskConsumer.enqueueTask(shadowTask);
    }
  }
}

protected void initializeTaskDone ( Set < TaskImageContainer > tasks , Optional < Runnable > runnableWhenDone ) { Set < CaptureSession > sessionSet = new HashSet < > ( ) ; Map < CaptureSession , Integer > sessionTaskCount = new HashMap < > ( ) ; for ( TaskImageContainer task : tasks ) { sessionSet . add ( task . mSession ) ; Integer currentCount = sessionTaskCount . get ( task . mSession ) ; if ( currentCount == null ) { sessionTaskCount . put ( task . mSession , 1 ) ; } else { sessionTaskCount . put ( task . mSession , currentCount + 1 ) ; } } synchronized ( mShadowTaskMap ) { for ( CaptureSession captureSession : sessionSet ) { BlockSignalProtocol protocol = new BlockSignalProtocol ( ) ; protocol . setCount ( sessionTaskCount . get ( captureSession ) ) ; final ImageShadowTask shadowTask ; shadowTask = new ImageShadowTask ( protocol , captureSession , runnableWhenDone ) ; mShadowTaskMap . put ( captureSession , shadowTask ) ; mProcessingTaskConsumer . enqueueTask ( shadowTask ) ; } } }
for a given set of starting tasks , initialize the associated sessions with a proper blocking semaphore and value of number of tasks to be run . for each semaphore , a imageshadowtask will be instantiated and enqueued onto the selected processingserivcemanager .
