예제 #1
0
  @Stop(priority = 20)
  @Override
  public void stop() {
    if (trace) {
      log.tracef(
          "Shutting down StateConsumer of cache %s on node %s", cacheName, rpcManager.getAddress());
    }

    try {
      synchronized (this) {
        // cancel all inbound transfers
        taskQueue.clear();
        for (Iterator<List<InboundTransferTask>> it = transfersBySource.values().iterator();
            it.hasNext(); ) {
          List<InboundTransferTask> inboundTransfers = it.next();
          it.remove();
          for (InboundTransferTask inboundTransfer : inboundTransfers) {
            inboundTransfer.cancel();
          }
        }
        transfersBySource.clear();
        transfersBySegment.clear();
      }
    } catch (Throwable t) {
      log.errorf(
          t,
          "Failed to stop StateConsumer of cache %s on node %s",
          cacheName,
          rpcManager.getAddress());
    }
  }
예제 #2
0
  private void refreshAll(final boolean updateSelection) {

    queue.clear();

    // We use a job for this as the file list can be large
    final Job refresh =
        new Job("Refresh Image Monitor") {
          @Override
          protected IStatus run(IProgressMonitor monitor) {

            Display.getDefault()
                .asyncExec(
                    new Runnable() {
                      @Override
                      public void run() {
                        galleryGroup.clearAll();
                        galleryGroup.setItemCount(info.getSize());
                        galleryGroup.setExpanded(true);
                        galleryGroup.setText(info.getName());

                        gallery.update();
                        gallery.getParent().layout(new Control[] {gallery});

                        GalleryItem item = galleryGroup.getItem(galleryGroup.getItemCount() - 1);
                        gallery.setSelection(new GalleryItem[] {item});
                      }
                    });

            return Status.OK_STATUS;
          }
        };
    refresh.setPriority(Job.INTERACTIVE);
    refresh.schedule();
  }
예제 #3
0
  public void clear() {
    queue.clear();
    galleryGroup.clearAll();
    galleryGroup.setItemCount(0);
    galleryGroup.setExpanded(true);
    galleryGroup.setText(groupLabel);

    gallery.update();
  }
예제 #4
0
 private static BlockingDeque<String> load(String name, BlockingDeque<String> queue)
     throws IOException {
   queue.clear();
   File saveFile = new File(Publisher.SAVE_FOLDER + "qidian-bobo-" + name + ".sav");
   if (saveFile.isFile()) {
     BufferedReader reader = new BufferedReader(new FileReader(saveFile));
     String line;
     while (null != (line = reader.readLine())) {
       if (!line.isEmpty()) {
         queue.add(line);
       }
     }
     reader.close();
   }
   return queue;
 }
예제 #5
0
  public void dispose() {
    queue.clear();
    queue.add(new ImageItem()); // stops queue.

    if (gallery != null && !gallery.isDisposed()) {
      // Dispose images, may be a lot!
      for (int i = 0; i < gallery.getItemCount(); ++i) {
        if (gallery.getItem(i).getImage() != null) {
          gallery.getItem(i).getImage().dispose();
        }
      }
      gallery.dispose();
    }

    // Nullify variables
    gallery = null;
    galleryGroup = null;
    queue = null;
    imageThread = null;
  }
 public void clear() {
   dualChannelPool.clear();
 }