Examples of Sync


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

    }

    public synchronized Object getObject(final Object key)
    throws IOException, ClassNotFoundException
    {
        Sync sync = this.lock.writeLock();
        try
        {
            sync.acquire();
            try
            {
                final File file = this.fileFromKey(key);
                if (file != null) {
                    return this.deserializeObject(file);
                }
            }
            finally
            {
                sync.release();
            }
        }
        catch (InterruptedException ignore)
        {
        }
View Full Code Here

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

     * @return the Object associated with Key Object
     */
    public Object get(Object key)
    {
        Object value = null;
        Sync sync = this.lock.readLock();
        try
        {
            sync.acquire();
            try
            {
                value = this.doGet(key);
            }
            finally
            {
                sync.release();
            }
        }
        catch (InterruptedException ignore)
        {
        }
View Full Code Here

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

     * @exception  IOException
     */
    public void store(Object key, Object value)
    throws IOException
    {
        Sync sync = this.lock.writeLock();
        try
        {
            sync.acquire();

            try
            {
                this.doStore(key, value);
                m_sizeInstrument.setValue( doGetSize() );
            }
            finally
            {
                sync.release();
            }
        }
        catch (InterruptedException ignore)
        {
        }
View Full Code Here

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

    /**
     * Frees some values of the data file.<br>
     */
    public void free()
    {
        Sync sync = this.lock.writeLock();
        try
        {
            sync.acquire();

            try
            {
                this.doFree();
                m_sizeInstrument.setValue( doGetSize() );
            }
            finally
            {
                sync.release();
            }
        }
        catch (InterruptedException ignore)
        {
        }
View Full Code Here

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

        if (getLogger().isDebugEnabled())
        {
            getLogger().debug("clear(): Clearing the database ");
        }

        Sync sync = this.lock.writeLock();
        try
        {
            sync.acquire();
            try
            {
                this.doClear();
                m_sizeInstrument.setValue( 0 );
            }
            finally
            {
                sync.release();
            }
        }
        catch (InterruptedException ignore)
        {
        }
View Full Code Here

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

        }

        // if we get here the following is true:
        // - the current thread does not hold a write lock
        for (;;) {
            Sync signal;
            // make sure writer state does not change
            Sync shared = writerStateRWLock.readLock();
            shared.acquire();
            try {
                if (activeWriter == null
                        || !hasDependency(activeWriter.changes, id)) {
                    readerCount.incrementAndGet();
                    readLockMap.addLock(id);
                    return new ReadLockImpl(id);
                } else {
                    signal = new Latch();
                    waitingReaders.add(signal);
                }
            } finally {
                shared.release();
            }

            // if we get here there was an active writer with
            // a dependency to the current id.
            // wait for the writer until it is done, then try again
View Full Code Here

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

     * {@inheritDoc}
     */
    public WriteLock acquireWriteLock(ChangeLog changeLog)
            throws InterruptedException {
        for (;;) {
            Sync signal;
            // we want to become the current writer
            Sync exclusive = writerStateRWLock.writeLock();
            exclusive.acquire();
            try {
                if (activeWriter == null
                        && !readLockMap.hasDependency(changeLog)) {
                    activeWriter = new WriteLockImpl(changeLog);
                    activeWriterId = getCurrentThreadId();
                    return activeWriter;
                } else {
                    signal = new Latch();
                    waitingWriters.add(signal);
                }
            } finally {
                exclusive.release();
            }
            // if we get here there is an active writer or there is a read
            // lock that conflicts with the change log
            signal.acquire();
        }
View Full Code Here

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

        WriteLockImpl(ChangeLog changes) {
            this.changes = changes;
        }

        public void release() {
            Sync exclusive = writerStateRWLock.writeLock();
            for (;;) {
                try {
                    exclusive.acquire();
                    break;
                } catch (InterruptedException e) {
                    // try again
                    Thread.interrupted();
                }
            }
            try {
                activeWriter = null;
                activeWriterId = null;
                notifyWaitingReaders();
                notifyWaitingWriters();
            } finally {
                exclusive.release();
            }
        }
View Full Code Here

Examples of edu.scripps.mwsync.Sync

      parser.accepts("p", "sync one page").withRequiredArg().ofType(String.class);
      parser.accepts("h", "changes since x hours ago").withRequiredArg().ofType(Integer.class);
      OptionSet options = parser.parse(args);
      String root = "/usr/local/bin/gwsync/";
      root =  (String) (options.hasArgument("r") ? options.valueOf("r") : root);
      Sync sync = Sync.newFromConfigFile(root+"sync.conf");
      String ncboAPIKey   = sync.getProperties().getProperty("ncbo.api.key");
      String doidFile    = sync.getProperties().getProperty("doid.file");
      sync.addRewriter(new GeneWikiEditor(root, ncboAPIKey, doidFile));
      if (options.hasArgument("p")) {
        sync.runForPages((String) options.valueOf("p"));
      } else if (options.hasArgument("h")) {
        sync.runChangesFromHoursAgo((Integer)options.valueOf("h"));
      } else {
        sync.run();
      }
    } 
View Full Code Here

Examples of net.sf.ehcache.concurrent.Sync

        }
        return element;
    }

    private void tryRemoveImmediately(final Object key, final boolean notifyListeners) {
        Sync syncForKey = ((CacheLockProvider)getInternalContext()).getSyncForKey(key);
        boolean writeLocked = false;
        try {
            writeLocked = syncForKey.tryLock(LockType.WRITE, 0);
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        } catch (Error e) {
            if (!(e.getClass().getName().equals("com.tc.exception.TCLockUpgradeNotSupportedError"))) {
               throw e;
            }
        }
        if (writeLocked) {
            try {
                removeInternal(key, true, notifyListeners, false, false);
            } finally {
                syncForKey.unlock(LockType.WRITE);
            }
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug(configuration.getName() + " cache: element " + key + " expired, but couldn't be inline evicted");
            }
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.