Package EDU.oswego.cs.dl.util.concurrent

Examples of EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet


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


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

    protected void initializeOther(AbstractPacket other) {
        initializeBrokersVisited();
        other.id = this.id;
        other.receiptRequired = this.receiptRequired;
        other.memoryUsage = this.memoryUsage;
        CopyOnWriteArraySet set = this.brokersVisited;
        if (set != null && !set.isEmpty()){
            other.brokersVisited = new CopyOnWriteArraySet(set);
        }
    }
View Full Code Here

        }
    }
   
    synchronized void initializeBrokersVisited(){
        if (this.brokersVisited == null){
            this.brokersVisited = new CopyOnWriteArraySet();
        }
    }
View Full Code Here

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

      else
      {
         loader.put(fqn, "k", "v");
      }
      final int loops = 1000;
      final Set exceptions = new CopyOnWriteArraySet();

      Thread remover1 = new Thread("Remover-1")
      {
         public void run()
         {
            try
            {
               latch.acquire();
               for (int i = 0; i < loops; i++)
               {
                  loader.remove(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
               }
            }
            catch (Exception e)
            {
               exceptions.add(e);
            }
         }
      };

      remover1.start();

      Thread remover2 = new Thread("Remover-2")
      {
         public void run()
         {
            try
            {
               latch.acquire();
               for (int i = 0; i < loops; i++)
               {
                  loader.remove(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())), "k");
               }
            }
            catch (Exception e)
            {
               exceptions.add(e);
            }
         }
      };

      remover2.start();


      Thread reader1 = new Thread("Reader-1")
      {
         public void run()
         {
            try
            {
               latch.acquire();
               for (int i = 0; i < loops; i++)
               {
                  loader.get(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
               }
            }
            catch (Exception e)
            {
               exceptions.add(e);
            }
         }
      };
      reader1.start();

      Thread reader2 = new Thread("Reader-2")
      {
         public void run()
         {
            try
            {
               latch.acquire();
               for (int i = 0; i < loops; i++)
               {
                  loader.getChildrenNames(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
               }
            }
            catch (Exception e)
            {
               exceptions.add(e);
            }
         }
      };
      reader2.start();


      Thread writer1 = new Thread("Writer-1")
      {
         public void run()
         {
            try
            {
               latch.acquire();
               for (int i = 0; i < loops; i++)
               {
                  loader.put(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())), "k", "v");
               }
            }
            catch (Exception e)
            {
               exceptions.add(e);
            }
         }
      };
      writer1.start();

      Thread writer2 = new Thread("Writer-2")
      {
         public void run()
         {
            try
            {
               latch.acquire();
               for (int i = 0; i < loops; i++)
               {
                  loader.put(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())), new HashMap());
               }
            }
            catch (Exception e)
            {
               exceptions.add(e);
            }
         }
      };
      writer2.start();


      latch.release();
      reader1.join();
      reader2.join();
      remover1.join();
      remover2.join();
      writer1.join();
      writer2.join();

      Exception e;
      for(Iterator it = exceptions.iterator(); it.hasNext();)
      {
         e = (Exception)it.next();
         throw e;
      }
   }
View Full Code Here

       {
          cache2.put(fqn, "k", "v");
          cache1.evict(fqn);
       }
       final int loops = 10000;
       final Set exceptions = new CopyOnWriteArraySet();

       Thread evictor = new Thread("Evictor")
       {
          public void run()
          {
             try
             {
                latch.acquire();
                for (int i = 0; i < loops; i++)
                {
                   Fqn f = singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size()));
                   cache1.evict(f);
                }
             }
             catch (TimeoutException te)
             {
                // doesn't matter if we hit these on occasion
             }
             catch (Exception e)
             {
                exceptions.add(e);
             }
          }
       };

       evictor.start();

       Thread writer = new Thread("Writer")
       {
          public void run()
          {
             try
             {
                latch.acquire();
                for (int i = 0; i < loops; i++)
                {
                   Fqn f = singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size()));
                   cache2.put(f, "k", "v");
                }
             }
             catch (Exception e)
             {
                exceptions.add(e);
             }
          }
       };

       writer.start();


       Thread reader1 = new Thread("Reader-1")
       {
          public void run()
          {
             try
             {
                latch.acquire();
                for (int i = 0; i < loops; i++)
                {
                   loader1.get(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
                }
             }
             catch (Exception e)
             {
                exceptions.add(e);
             }
          }
       };
       reader1.start();

       Thread reader2 = new Thread("Reader-2")
       {
          public void run()
          {
             try
             {
                latch.acquire();
                for (int i = 0; i < loops; i++)
                {
                   loader1.getChildrenNames(singleFqn ? fqn.getParent() : ((Fqn)fqns.get(r.nextInt(fqns.size()))).getParent());
                }
             }
             catch (Exception e)
             {
                exceptions.add(e);
             }
          }
       };
       reader2.start();

       Thread reader3 = new Thread("Reader-3")
       {
          public void run()
          {
             try
             {
                latch.acquire();
                for (int i = 0; i < loops; i++)
                {
                   loader1.getChildrenNames(singleFqn ? fqn : (Fqn)fqns.get(r.nextInt(fqns.size())));
                }
             }
             catch (Exception e)
             {
                exceptions.add(e);
             }
          }
       };
       reader3.start();

       latch.release();
       reader1.join();
       reader2.join();
       reader3.join();
       evictor.join();
       writer.join();

       Exception e;
       for(Iterator it = exceptions.iterator(); it.hasNext();)
       {
          e = (Exception)it.next();
          throw e;
       }
    }
View Full Code Here

     */
    protected void initializeOther(AbstractPacket other) {
        initializeBrokersVisited();
        other.id = this.id;
        other.receiptRequired = this.receiptRequired;
        CopyOnWriteArraySet set = this.brokersVisited;
        if (set != null && !set.isEmpty()){
            other.brokersVisited = new CopyOnWriteArraySet(set);
        }
    }
View Full Code Here

        }
    }
   
    synchronized void initializeBrokersVisited(){
        if (this.brokersVisited == null){
            this.brokersVisited = new CopyOnWriteArraySet();
        }
    }
View Full Code Here

    protected void initializeOther(AbstractPacket other) {
        initializeBrokersVisited();
        other.id = this.id;
        other.receiptRequired = this.receiptRequired;
        other.memoryUsage = this.memoryUsage;
        CopyOnWriteArraySet set = this.brokersVisited;
        if (set != null && !set.isEmpty()){
            other.brokersVisited = new CopyOnWriteArraySet(set);
        }
    }
View Full Code Here

TOP

Related Classes of EDU.oswego.cs.dl.util.concurrent.CopyOnWriteArraySet

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.