diff --git a/parsing.lucene/apichanges.xml b/parsing.lucene/apichanges.xml --- a/parsing.lucene/apichanges.xml +++ b/parsing.lucene/apichanges.xml @@ -110,6 +110,24 @@ + + + Added IndexManager.priorityAccess to suspend IO during query + + + + + +

+ Added IndexManager.priorityAccess to suspend background scan + and checking for external changes during query. The methods IndexManager.readAccess + and IndexManager.writeAccess were deprecated. The Index is now self + guarded and global lock is not needed for correct synchronization. +

+
+ + +
Added RAM implementation of Index diff --git a/parsing.lucene/manifest.mf b/parsing.lucene/manifest.mf --- a/parsing.lucene/manifest.mf +++ b/parsing.lucene/manifest.mf @@ -2,5 +2,5 @@ AutoUpdate-Show-In-Client: false OpenIDE-Module: org.netbeans.modules.parsing.lucene/2 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/parsing/lucene/Bundle.properties -OpenIDE-Module-Specification-Version: 2.8 +OpenIDE-Module-Specification-Version: 2.9 diff --git a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/IndexManager.java b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/IndexManager.java --- a/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/IndexManager.java +++ b/parsing.lucene/src/org/netbeans/modules/parsing/lucene/support/IndexManager.java @@ -101,7 +101,11 @@ * @return the result of the action * @throws IOException when the action throws {@link IOException} * @throws InterruptedException when the action throws {@link InterruptedException} + * @deprecated The {@link Index} is self guarded and global lock acquired by + * {@link IndexManager#writeAccess} is not needed for correct synchronization. + * To suspend the scan and external changes check during the action use {@link IndexManager#priorityAccess}. */ + @Deprecated public static R writeAccess (final Action action) throws IOException, InterruptedException { assert action != null; lock.writeLock().lock(); @@ -134,7 +138,11 @@ * @return the result of the action * @throws IOException when the action throws {@link IOException} * @throws InterruptedException when the action throws {@link InterruptedException} + * @deprecated The {@link Index} is self guarded and global lock acquired by + * {@link IndexManager#readAccess} is not needed for correct synchronization. + * To suspend the scan and external changes check during the action use {@link IndexManager#priorityAccess}. */ + @Deprecated public static R readAccess (final Action action) throws IOException, InterruptedException { assert action != null; suspend(); @@ -165,6 +173,42 @@ resume(); } } + + /** + * Runs the given action as a priority action. + * During the priority action scan and checking for external changes are + * suspended. + * @param action the action to be performed. + * @return the result of the action + * @throws IOException when the action throws {@link IOException} + * @throws InterruptedException when the action throws {@link InterruptedException} + * @since 2.9 + */ + public static R priorityAccess(final Action action) throws IOException, InterruptedException { + assert action != null; + suspend(); + try { + return ProvidedExtensions.priorityIO(new Callable() { + @Override + public R call() throws Exception { + return action.run(); + } + }); + } catch (IOException ioe) { + //rethrow ioe + throw ioe; + } catch (InterruptedException ie) { + //rethrow ioe + throw ie; + } catch (RuntimeException re) { + //rethrow ioe + throw re; + } catch (Exception e) { + throw new IOException(e); + } finally { + resume(); + } + } /** * Checks if the caller thread holds the {@link IndexManager}'s write lock