Package com.aelitis.azureus.core.util

Examples of com.aelitis.azureus.core.util.CopyOnWriteList


    if (true == shouldIgnore()) {
      return;
    }
    if (null != listener) {
      if (null == reporterListeners) {
        reporterListeners = new CopyOnWriteList();
        reporterListeners.add(listener);
      } else if (false == reporterListeners.contains(listener)) {
        reporterListeners.add(listener);
      }
    }
View Full Code Here


        Debug.printStackTrace(e);
      }
    }
   
    listeners_ref = null;
    CopyOnWriteList write_listeners = (CopyOnWriteList)listeners_write_map_cow.get(attribute_name);
    if (write_listeners != null) {listeners_ref = write_listeners.getList();}
   
    if (listeners_ref != null) {
      for (int i=0;i<listeners_ref.size();i++) {
        try {((DownloadManagerStateAttributeListener)listeners_ref.get(i)).attributeEventOccurred(download_manager, attribute_name, DownloadManagerStateAttributeListener.WRITTEN);}
        catch (Throwable t) {Debug.printStackTrace(t);}
View Full Code Here

            Debug.printStackTrace(e);
          }
        }
       
        listeners_ref = null;
        CopyOnWriteList read_listeners = null;
       
        read_listeners = (CopyOnWriteList)listeners_read_map_cow.get(attribute_name);
        if (read_listeners != null) {listeners_ref = read_listeners.getList();}
       
        if (listeners_ref != null) {
          for (int i=0;i<listeners_ref.size();i++) {
            try {((DownloadManagerStateAttributeListener)listeners_ref.get(i)).attributeEventOccurred(download_manager, attribute_name, DownloadManagerStateAttributeListener.WILL_BE_READ);}
            catch (Throwable t) {Debug.printStackTrace(t);}
View Full Code Here

    listeners_cow.remove(l);
  }
 
  public void addListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) {
    CopyOnWriteMap map_to_use = (event_type == DownloadManagerStateAttributeListener.WILL_BE_READ) ? this.listeners_read_map_cow : this.listeners_write_map_cow;
    CopyOnWriteList lst = (CopyOnWriteList)map_to_use.get(attribute);
    if (lst == null) {
      lst = new CopyOnWriteList();
      map_to_use.put(attribute, lst);
    }
    lst.add(l);
  }
View Full Code Here

    lst.add(l);
  }

  public void removeListener(DownloadManagerStateAttributeListener l, String attribute, int event_type) {
    CopyOnWriteMap map_to_use = (event_type == DownloadManagerStateAttributeListener.WILL_BE_READ) ? this.listeners_read_map_cow : this.listeners_write_map_cow;
    CopyOnWriteList lst = (CopyOnWriteList)map_to_use.get(attribute);
    if (lst != null) {lst.remove(l);}
  }
View Full Code Here

      final TOTorrentCreator c = TOTorrentFactory.createFromFileOrDirWithComputedPieceLength( data, announce_url, include_other_hashes);

      return(
        new TorrentCreator()
        {
          private CopyOnWriteList  listeners = new CopyOnWriteList();

          public void
          start()
          {
            c.addListener(
              new TOTorrentProgressListener()
              {
                public void
                reportProgress(
                  int    percent_complete )
                {
                  for (Iterator it=listeners.iterator();it.hasNext();){

                    ((TorrentCreatorListener)it.next()).reportPercentageDone( percent_complete );
                  }
                }

                public void
                reportCurrentTask(
                  String  task_description )
                {
                  for (Iterator it=listeners.iterator();it.hasNext();){

                    ((TorrentCreatorListener)it.next()).reportActivity( task_description );
                  }
                }
              });

            new AEThread( "TorrentManager::create", true )
            {
              public void
              runSupport()
              {
                try{
                  TOTorrent  t = c.create();

                  Torrent  torrent = new TorrentImpl( plugin_interface, t );

                  for (Iterator it=listeners.iterator();it.hasNext();){

                    ((TorrentCreatorListener)it.next()).complete( torrent );
                  }

                }catch( TOTorrentException e ){

                  for (Iterator it=listeners.iterator();it.hasNext();){

                    ((TorrentCreatorListener)it.next()).failed( new TorrentException( e ));
                  }

                }
              }
            }.start();
          }

          public void
          cancel()
          {
            c.cancel();
          }

          public void
          addListener(
            TorrentCreatorListener listener )
          {
            listeners.add( listener );
          }

          public void
          removeListener(
            TorrentCreatorListener listener )
          {
            listeners.remove( listener );
          }
        });

    }catch( TOTorrentException e ){
View Full Code Here

  addListener(
    final DiskManagerFileInfoListener  listener )
  {
    if ( listeners == null ){
     
      listeners = new CopyOnWriteList();
    }
   
    synchronized( listeners ){
     
      if ( listeners.getList().contains( listener )){
View Full Code Here

  /**
   *
   */
  private TableStructureEventDispatcher() {
    listeners = new CopyOnWriteList(2);
  }
View Full Code Here

    peer_id[0]='E';
    peer_id[1]='x';
    peer_id[2]='t';
    peer_id[3]=' ';
   
    listeners = new CopyOnWriteList();
    listeners_mon  = plugin.getPluginInterface().getUtilities().getMonitor();
   
    _reader.addListener( this );
  }
View Full Code Here

  public void addAttributeListener(DownloadAttributeListener listener, TorrentAttribute attr, int event_type) {
    String attribute = convertAttribute(attr);
    if (attribute == null) {return;}
   
    CopyOnWriteMap attr_map = this.getAttributeMapForType(event_type);
    CopyOnWriteList listener_list = (CopyOnWriteList)attr_map.get(attribute);
    boolean add_self = false;
   
    if (listener_list == null) {
      listener_list = new CopyOnWriteList();
      attr_map.put(attribute, listener_list);
    }
    add_self = listener_list.isEmpty();
   
    listener_list.add(listener);
    if (add_self) {
      download_manager.getDownloadState().addListener(this, attribute, event_type);
    }
  }
View Full Code Here

TOP

Related Classes of com.aelitis.azureus.core.util.CopyOnWriteList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.