/** Tests whether this thread has already entered the mutex in write access. * If it returns true, calling <code>writeAccess</code> will be executed * immediatelly without any other blocking. <code>postReadAccess</code> * will be delayed until a write access runnable is over. * * @return true if the thread is in write access section * @since 4.48 */ public boolean isWriteAccess() { if (this == EVENT) { return javax.swing.SwingUtilities.isEventDispatchThread(); } if (wrapper != null) { Mutex m = (Mutex)LOCK; return m.isWriteAccess(); } Thread t = Thread.currentThread(); ThreadInfo info; synchronized (LOCK) { info = getThreadInfo(t); if (info != null) { if (info.counts[X] > 0) { return true; } } } return false; }
if (m.isWriteAccess() || m.isReadAccess()) { run.run(); } else {
public void execute(Runnable command) { boolean ea = false; assert ea = true; if (ea) { Mutex mutex = getPMMutex(); if (mutex != null && (mutex.isReadAccess() || mutex.isWriteAccess())) { throw new IllegalStateException("Should not acquire Children.MUTEX while holding ProjectManager.mutex()"); } } command.run(); }
/** Updates the state of children by adding given Infos. * @param infos list of Info objects to add * @param entries the final state of entries that should occur */ private void updateAdd(Collection<Info> infos, List<Entry> entries) { assert Children.MUTEX.isWriteAccess(); List<Node> nodes = new LinkedList<Node>(); for (Info info : infos) { nodes.addAll(info.nodes(false)); map.put(info.entry, info); } if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("Entries before updateAdd(): " + this.entries); LOGGER.finer("Entries after updateAdd(): " + entries); } this.entries = entries; checkConsistency(); if (!nodes.isEmpty()) { clearNodes(); notifyAdd(nodes); } }
/** Removes the objects from the children. */ private void updateRemove(Node[] current, Set<Entry> toRemove) { assert Children.MUTEX.isWriteAccess(); List<Node> nodes = new LinkedList<Node>(); ChildrenArray cha = array.get(); for (Entry en : toRemove) { Info info = map.remove(en); checkInfo(info, en, null, map); nodes.addAll(info.nodes(true)); cha.remove(info); } // modify the current set of entries entries.removeAll(toRemove); checkConsistency(); if (LOGGER.isLoggable(Level.FINER)) { LOGGER.finer("Current : " + this.entries); LOGGER.finer("Removing: " + toRemove); } // empty the list of nodes so it has to be recreated again if (!nodes.isEmpty()) { clearNodes(); notifyRemove(nodes, current); } }
@Override protected void setEntries(Collection<? extends Entry> entries, boolean noCheck) { assert noCheck || Children.MUTEX.isWriteAccess(); final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER);
if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess() || (initThread == Thread.currentThread())) { LOGGER.log(Level.FINER, "cannot initialize better " + this + " on " + Thread.currentThread() + " read access: " + Children.MUTEX.isReadAccess() + " write access: " + Children.MUTEX.isWriteAccess() + " initThread: " + initThread);
assert Children.MUTEX.isWriteAccess(); EntrySupportLazyState state = stateHolder[0]; List<Entry> toAdd = new LinkedList<Entry>();
assert Children.MUTEX.isWriteAccess(); List<Info> toAdd = new LinkedList<Info>();
private boolean checkSupportChanged() { FilterChildrenSupport support = (FilterChildrenSupport) entrySupport(); EntrySupport origSupport = original.getChildren().entrySupport(); if (support.originalSupport() != origSupport) { assert Children.MUTEX.isWriteAccess() : "Should be called only under write access"; // NOI18N changeSupport(null); return true; } else { return false; } }
@Override void setEntries(Collection<? extends Entry> newEntries, boolean noCheck) { assert Children.MUTEX.isWriteAccess(); for (;;) { EntrySupportLazyState[] stateHolder = { null };
if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess() || (state.initThread() == Thread.currentThread())) { if (LOG_ENABLED) { LOGGER.log(Level.FINER, "Cannot wait for finished initialization " + this + " on " + Thread.currentThread() + " read access: " + Children.MUTEX.isReadAccess() + " write access: " + Children.MUTEX.isWriteAccess() + " initThread: " + state.initThread());
boolean justHide, boolean delayed ) { assert Children.MUTEX.isWriteAccess(); final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER); if (LOG_ENABLED) {
@Override void refreshEntry(Entry entry) { assert Children.MUTEX.isWriteAccess(); final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER); if (LOG_ENABLED) {
private void unloadIndexingContext(final String repo) throws IOException { assert getRepoMutex(repo).isWriteAccess(); LOGGER.log(Level.FINE, "Unloading Context: {0}", repo); IndexingContext ic = getIndexingContexts().get(repo); if (ic != null) { removeIndexingContext(ic, false); } }
public GuardedActions(int type, Object p1) { this.type = type; this.p1 = p1; if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess()) { ret = run(); } else { ret = Children.MUTEX.readAccess(this); } }
/** * Mark this project as being modified without actually changing anything in it. * Should only be called from {@link ProjectGenerator#createProject}. */ public void markModified() { assert ProjectManager.mutex().isWriteAccess(); state.markModified(); // To make sure projectXmlSaved is called: addModifiedMetadataPath(PROJECT_XML_PATH); }
public GuardedActions(int type, Object p1) { this.type = type; this.p1 = p1; if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess()) { ret = run(); } else { ret = Children.MUTEX.readAccess(this); } }
@SuppressWarnings({"OverridableMethodCallInConstructor", "LeakingThisInConstructor"}) public GuardedActions(int type, Object p1) { this.type = type; this.p1 = p1; if (Children.MUTEX.isReadAccess() || Children.MUTEX.isWriteAccess()) { ret = run(); } else { ret = Children.MUTEX.readAccess(this); } }
/** * Load <references> from project.xml. * @return can return null if there are no references stored yet */ private Element loadReferences() { assert ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess(); Element references = aux.getConfigurationFragment(REFS_NAME, REFS_NS2, true); if (references == null) { references = aux.getConfigurationFragment(REFS_NAME, REFS_NS, true); } return references; }