Examples of CopyOnWriteArraySet


Examples of java.util.concurrent.CopyOnWriteArraySet

   public void addPerInstanceJoinpointAspect(Joinpoint joinpoint, AspectDefinition def)
   {
      Set joinpoints = (Set) perInstanceJoinpointAspectDefinitions.get(def);
      if (joinpoints == null)
      {
         joinpoints = new CopyOnWriteArraySet();
         initPerInstanceJoinpointAspectDefinitionsMap();
         perInstanceJoinpointAspectDefinitions.put(def, joinpoints);
         def.registerAdvisor(this);
      }
      joinpoints.add(joinpoint);
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

   {
      initPerInstanceJoinpointAspectDefinitionsMap();
      Set setJoinpoints = (Set) perInstanceJoinpointAspectDefinitions.get(def);
      if (setJoinpoints == null)
      {
         setJoinpoints = new CopyOnWriteArraySet();
         perInstanceJoinpointAspectDefinitions.put(def, setJoinpoints);
         def.registerAdvisor(this);
      }
      setJoinpoints.addAll(joinpoints);
   }
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

         lockWrite();
         try
         {
            if (perInstanceAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET)
            {
               perInstanceAspectDefinitions = new CopyOnWriteArraySet();
            }
         }
         finally
         {
            unlockWrite();
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

        _delegate.addRoot(corrRoot);
        return corrRoot;
    }
   
    public Set<Join<?,?>> getCorrelatedJoins() {
        return _corrJoins == null ? Collections.emptySet() : new CopyOnWriteArraySet(_corrJoins);
    }
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

    //TODO: Use the much better-written MusicPanel populateDropdownBox to refactor this mess
    @Override
    protected void populateDropdownBox()
    {
        currentDropdown.removeAllItems();
        Set heroList = new CopyOnWriteArraySet();
        //Build list of heroes and populate dropwdown with it               
        File file = new File(vpkPath);
        VPKArchive vpk = new VPKArchive();

        System.out.println(file);

        try
        {
            vpk.load(file);
        }
        catch (Exception ex)
        {
            System.err.println("Can't open archive: " + ex.getMessage());
            return;
        }

        for (VPKEntry entry : vpk.getEntries())
        {
            if (entry.getPath().contains("scripts/game_sounds_heroes/"))
            {
                heroList.add(entry.getName());
            }
        }
        //Format and prettify hero list
        for (Object hero : heroList)
        {
            String heroString = hero.toString();
            heroString = heroString.replace("game_sounds_", "");
            NamedHero tempNamedHero = new NamedHero(heroString);
            heroList.remove(hero);
            heroList.add(tempNamedHero);
        }
        Object[] heroListArray = heroList.toArray();
        Arrays.sort(heroListArray);
        for (Object h : heroListArray)
        {
            NamedHero tempHero = (NamedHero) h;
            currentDropdown.addItem(tempHero);
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

   /**
    * Defines the concurrent set implementation
    */
   public static final Set createCopyOnWriteSet()
   {
      return new CopyOnWriteArraySet();
   }
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

        final List permanentObjects = new ArrayList();
        // a set of objects that will be added and removed at random to the test set to force rehashing
        final List volatileObjects = new ArrayList();
        permanentObjects.addAll(createWithRandomIntegers(80, null));
        volatileObjects.addAll(createWithRandomIntegers(10000, permanentObjects));
        final CopyOnWriteArraySet missing = new CopyOnWriteArraySet();
        final int mutatorThreshold = 1000;

        // Add elements that will not be touched by the constantly running mutating thread
        for (Object permanent : permanentObjects) {
            testSet.add(permanent);
        }

        // Adds and removes items
        // thus forcing constant rehashing of the backing hashtable
        Runnable rehasher = new Runnable() {
            public void run() {
                Random rand = new Random();
                for(int times = 0; times < 1000 ; times++){
                    HashSet elements = new HashSet(mutatorThreshold);

                    for (int i = 0; i < mutatorThreshold; i++) {
                        Object volatileObject = volatileObjects.get(Math.abs(rand.nextInt()) % volatileObjects.size());
                        testSet.add(volatileObject);
                        elements.add(volatileObject);
                    }
                    for (Object volObj : elements) {
                        testSet.remove(volObj);
                    }
                }
            };
        };

        Runnable lookup = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10000; i++) {
                    for (Object permanent : permanentObjects) {
                        // permanent items are never touched,
                        // --> set.contains(j) should always return true
                        if(!testSet.contains(permanent))
                            missing.add(permanent);
                    }
                }
            }
        };

        ConcurrentExecutor.runConcurrent(rehasher, lookup, lookup, lookup);
        assertTrue("There where items temporarily unavailable: " + missing.size(), missing.size() == 0);

    }
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

   public void addPerInstanceJoinpointAspect(Joinpoint joinpoint, AspectDefinition def)
   {
      Set joinpoints = (Set) perInstanceJoinpointAspectDefinitions.get(def);
      if (joinpoints == null)
      {
         joinpoints = new CopyOnWriteArraySet();
         initPerInstanceJoinpointAspectDefinitionsMap();
         perInstanceJoinpointAspectDefinitions.put(def, joinpoints);
         def.registerAdvisor(this);
      }
      joinpoints.add(joinpoint);
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

   {
      initPerInstanceJoinpointAspectDefinitionsMap();
      Set setJoinpoints = (Set) perInstanceJoinpointAspectDefinitions.get(def);
      if (setJoinpoints == null)
      {
         setJoinpoints = new CopyOnWriteArraySet();
         perInstanceJoinpointAspectDefinitions.put(def, setJoinpoints);
         def.registerAdvisor(this);
      }
      setJoinpoints.addAll(joinpoints);
   }
View Full Code Here

Examples of java.util.concurrent.CopyOnWriteArraySet

         lockWrite();
         try
         {
            if (perInstanceAspectDefinitions == UnmodifiableEmptyCollections.EMPTY_COPYONWRITE_ARRAYSET)
            {
               perInstanceAspectDefinitions = new CopyOnWriteArraySet();
            }
         }
         finally
         {
            unlockWrite();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.