Examples of ReentrantLock


Examples of java.util.concurrent.locks.ReentrantLock

      throw new HibernateException( "Unable to initialize index: " + indexName, e );
    }
    configureOptimizerStrategy(searchFactoryImplementor, indexProps, this);
    configureIndexingParameters(searchFactoryImplementor, indexProps, this);
    if ( !searchFactoryImplementor.getLockableDirectoryProviders().containsKey( this ) ) {
      searchFactoryImplementor.getLockableDirectoryProviders().put( this, new ReentrantLock() );
    }
  }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

      }
    }
    Set<DirectoryProvider> providers = searchFactoryImplementor.getLockableDirectoryProviders().keySet();
    perDirectoryProviderManipulationLocks = new HashMap<DirectoryProvider, Lock>( providers.size() );
    for (DirectoryProvider dp : providers) {
      perDirectoryProviderManipulationLocks.put( dp, new ReentrantLock() );
    }
    /***********hibernate search code**********
    perDirectoryProviderManipulationLocks = Collections.unmodifiableMap( perDirectoryProviderManipulationLocks );
    ******************************************/
  }
 
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

  }

  /****************add by Jerry*************/
  public void addLock(DirectoryProvider dp){
    if(perDirectoryProviderManipulationLocks.get(dp)==null)
    perDirectoryProviderManipulationLocks.put( dp, new ReentrantLock() );
  }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

    else {
      configureOptimizerStrategy(searchFactoryImplementor, indexProps, provider);
      configureIndexingParameters(searchFactoryImplementor, indexProps, provider);
      providers.add( provider );
      if ( !searchFactoryImplementor.getLockableDirectoryProviders().containsKey( provider ) ) {
        searchFactoryImplementor.getLockableDirectoryProviders().put( provider, new ReentrantLock() );
      }
      return provider;
    }
  }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

public class LockDelegate implements ILock {

    private final Lock delegate;
   
    public LockDelegate() {
        this.delegate = new ReentrantLock(true);
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

        }
    }

    public static class NoCleanUpRemoteProcess implements Action<WorkerProcessContext>, Serializable {
        public void execute(WorkerProcessContext workerProcessContext) {
            final Lock lock = new ReentrantLock();
            lock.lock();
            new Thread(new Runnable() {
                public void run() {
                    lock.lock();
                }
            }).start();

            TestListenerInterface sender = workerProcessContext.getServerConnection().addOutgoing(
                    TestListenerInterface.class);
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

            }
        });
        current = new HashMap<String, SourceSequence>();
       
        retransmissionQueue = new RetransmissionQueue(h, getRMAssertion());        
        sequenceCreationLock = new ReentrantLock();
        sequenceCreationCondition = sequenceCreationLock.newCondition();
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

    public void testSchedule() throws Exception {
        workqueue = new AutomaticWorkQueueImpl(UNBOUNDED_MAX_QUEUE_SIZE, INITIAL_SIZE,
                                               UNBOUNDED_HIGH_WATER_MARK,
                                               UNBOUNDED_LOW_WATER_MARK,
                                               DEFAULT_DEQUEUE_TIMEOUT);
        final Lock runLock = new ReentrantLock();
        final Condition runCondition = runLock.newCondition();
        long start = System.currentTimeMillis();
        Runnable doNothing = new Runnable() {
            public void run() {
                runLock.lock();
                try {
                    runCondition.signal();
                } finally {
                    runLock.unlock();
                }
            }
        };
       
        workqueue.schedule(doNothing, 5000);
       
        runLock.lock();
        try {
            runCondition.await();
        } finally {
            runLock.unlock();
        }
       
        assertTrue("expected delay",
                   System.currentTimeMillis() - start >= 4950);
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

    }

    public void setUp() throws BusException {
        bus = EasyMock.createMock(Bus.class);
        wsdlManager = new WSDLManagerImpl(null);
        partialResponseReceivedLock = new ReentrantLock();
        partialResponseReceivedCondition = partialResponseReceivedLock.newCondition();
        partialResponseReceivedNotified = false;
        responseCallback = new TestResponseCallback();
        clientBinding = EasyMock.createMock(ClientBinding.class);
    }
View Full Code Here

Examples of java.util.concurrent.locks.ReentrantLock

  @SuppressWarnings("unused")
  private void asyncSetState(final Collection<INews> news, final State state, final boolean affectEquivalentNews, final boolean force) throws PersistenceException {
    if (news.isEmpty())
      return;
    final NewsEventRunnable eventRunnable = new NewsEventRunnable();;
    final Lock setStateLock = new ReentrantLock();
    setStateLock.lock();
    final Condition condition = setStateLock.newCondition();
    fExecutorService.execute(new Runnable() {
      public void run() {
        Set<INews> changedNews = null;
        try {
          fWriteLock.lock();
          setStateLock.lock();

          if (affectEquivalentNews) {
            /*
             * Give extra 25% size to take into account news that have same guid or
             * link.
             */
            int capacity = news.size() + (news.size() / 4);
            changedNews = new HashSet<INews>(capacity);
            for (INews newsItem : news) {
              if (newsItem.getId() == null)
                throw new IllegalArgumentException("newsItem was never saved to the database"); //$NON-NLS-1$

              List<INews> equivalentNews;

              if (newsItem.getGuid() != null) {
                equivalentNews = getNewsFromGuid(newsItem, true);
                if (equivalentNews.isEmpty()) {
                  throw createIllegalException("No news were found with guid: " + //$NON-NLS-1$
                      newsItem.getGuid().getValue(), newsItem);
                }
              } else if (newsItem.getLinkAsText() != null) {
                equivalentNews = getNewsFromLink(newsItem, true);
                if (equivalentNews.isEmpty()) {
                  throw createIllegalException("No news were found with link: " + //$NON-NLS-1$
                      newsItem.getLinkAsText(), newsItem);
                }
              } else
                equivalentNews = Collections.singletonList(newsItem);

              changedNews.addAll(setState(equivalentNews, state, force));
            }
          } else {
            changedNews = setState(news, state, force);
          }
          for (INews changedNewsItem : changedNews) {
            //TODO Investigate why we add the news twice to the event runnable
            //(we do the same in the finally block). This is harmless but
            //wasteful. Also we should not release the news locks before firing
            //the events.
            ((News) changedNewsItem).acquireReadLockSpecial();
            eventRunnable.addCheckedUpdateEvent(createSaveEventTemplate(changedNewsItem));
          }
          condition.signal();
          setStateLock.unlock();
          save(changedNews);
          fDb.commit();
        } catch (Db4oException e) {
          throw new PersistenceException(e);
        } finally {
          if (changedNews != null) {
            for (INews changedNewsItem : changedNews) {
              ((News) changedNewsItem).releaseReadLockSpecial();
              eventRunnable.addCheckedUpdateEvent(createSaveEventTemplate(changedNewsItem));
            }
          }
          DBHelper.cleanUpEvents();
          fWriteLock.unlock();
        }
      }
    });
    try {
      condition.awaitUninterruptibly();
    } finally {
      setStateLock.unlock();
    }
    eventRunnable.run();
  }
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.