本文整理了Java中org.openide.util.Mutex.isWriteAccess()
方法的一些代码示例,展示了Mutex.isWriteAccess()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mutex.isWriteAccess()
方法的具体详情如下:
包路径:org.openide.util.Mutex
类名称:Mutex
方法名:isWriteAccess
[英]Tests whether this thread has already entered the mutex in write access. If it returns true, calling writeAccess
will be executed immediatelly without any other blocking. postReadAccess
will be delayed until a write access runnable is over.
[中]测试此线程是否已在写访问中进入互斥锁。如果返回true,调用writeAccess
将立即执行,无需任何其他阻塞。postReadAccess
将被延迟,直到写入访问可运行结束。
代码示例来源:origin: org.netbeans.api/org-openide-util
/** 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;
}
代码示例来源:origin: org.netbeans.api/org-openide-util
if (m.isWriteAccess() || m.isReadAccess()) {
run.run();
} else {
代码示例来源:origin: org.netbeans.api/org-openide-nodes
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();
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
/** 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);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-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);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
@Override
protected void setEntries(Collection<? extends Entry> entries, boolean noCheck) {
assert noCheck || Children.MUTEX.isWriteAccess();
final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER);
代码示例来源:origin: org.netbeans.api/org-openide-nodes
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);
代码示例来源:origin: org.netbeans.api/org-openide-nodes
assert Children.MUTEX.isWriteAccess();
EntrySupportLazyState state = stateHolder[0];
List<Entry> toAdd = new LinkedList<Entry>();
代码示例来源:origin: org.netbeans.api/org-openide-nodes
assert Children.MUTEX.isWriteAccess();
List<Info> toAdd = new LinkedList<Info>();
代码示例来源:origin: org.netbeans.api/org-openide-nodes
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;
}
}
代码示例来源:origin: org.netbeans.api/org-openide-nodes
@Override
void setEntries(Collection<? extends Entry> newEntries, boolean noCheck) {
assert Children.MUTEX.isWriteAccess();
for (;;) {
EntrySupportLazyState[] stateHolder = { null };
代码示例来源:origin: org.netbeans.api/org-openide-nodes
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());
代码示例来源:origin: org.netbeans.api/org-openide-nodes
boolean justHide, boolean delayed
) {
assert Children.MUTEX.isWriteAccess();
final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER);
if (LOG_ENABLED) {
代码示例来源:origin: org.netbeans.api/org-openide-nodes
@Override
void refreshEntry(Entry entry) {
assert Children.MUTEX.isWriteAccess();
final boolean LOG_ENABLED = LOGGER.isLoggable(Level.FINER);
if (LOG_ENABLED) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-maven-indexer
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);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
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);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-makeproject
/**
* 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);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
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);
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@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);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby-rakeproject
/**
* 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;
}
内容来源于网络,如有侵权,请联系作者删除!