本文整理了Java中org.openide.util.Mutex.setGrantedMode()
方法的一些代码示例,展示了Mutex.setGrantedMode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mutex.setGrantedMode()
方法的具体详情如下:
包路径:org.openide.util.Mutex
类名称:Mutex
方法名:setGrantedMode
暂无
代码示例来源:origin: org.netbeans.api/org-openide-util
setGrantedMode(CHAIN);
cell = chain(mode, t, Integer.MAX_VALUE);
waiters.remove(0);
setGrantedMode(mode);
setGrantedMode(NONE);
wakeUpOthers();
代码示例来源:origin: org.netbeans.api/org-openide-util
setGrantedMode(S);
} else {
info.mode = NONE;
setGrantedMode(NONE);
registeredThreads.remove(info.t);
代码示例来源:origin: org.netbeans.api/org-openide-util
private void wakeUpReaders() {
assert (grantedMode == NONE) || (grantedMode == S);
if (waiters.isEmpty()) {
return;
}
for (int i = 0; i < waiters.size(); i++) {
QueueCell qc = waiters.get(i);
synchronized (qc) {
if (qc.isGotOut()) {
// bogus waiter
waiters.remove(i--);
continue;
}
if (qc.mode == S) { // readers only
waiters.remove(i--);
qc.wakeMeUp();
setGrantedMode(S);
if (getThreadInfo(qc.t) == null) {
// force to have a record since recorded threads
// do not use isCompatible call
ThreadInfo ti = new ThreadInfo(qc.t, qc.mode);
ti.forced = true;
readersNo++;
registeredThreads.put(qc.t, ti);
}
}
}
// sync (qc)
}
}
代码示例来源:origin: org.netbeans.api/org-openide-util
waiters.remove(i--);
qc.wakeMeUp();
setGrantedMode(qc.mode);
setGrantedMode(CHAIN);
代码示例来源:origin: org.netbeans.api/org-openide-util
info.rsnapshot = info.counts[S];
if (grantedMode == S) {
setGrantedMode(X);
} else if (grantedMode == X) {
setGrantedMode(requested);
registeredThreads.put(t,
info = new ThreadInfo(t, requested));
return false;
setGrantedMode(CHAIN);
cell = chain(requested, t, 0);
代码示例来源:origin: org.netbeans.api/org-openide-util
setGrantedMode(NONE);
setGrantedMode(X);
代码示例来源:origin: org.netbeans.api/org-openide-util
private boolean reenterImpl(Thread t, int mode) {
// from leaveX -> grantedMode is NONE or S
if (mode == S) {
if ((grantedMode != NONE) && (grantedMode != S)) {
throw new IllegalStateException(this.toString());
}
enter(mode, t, true);
return false;
}
// assert (mode == X)
ThreadInfo tinfo = getThreadInfo(t);
boolean chainFromLeaveX = ((grantedMode == CHAIN) && (tinfo != null) && (tinfo.counts[X] > 0));
// process grantedMode == X or CHAIN from leaveX OR grantedMode == NONE from leaveS
if ((grantedMode == X) || (grantedMode == NONE) || chainFromLeaveX) {
enter(mode, t, true);
return false;
} else { // remains grantedMode == CHAIN or S from leaveS, so it will be CHAIN
if (readersNo == 0) {
throw new IllegalStateException(this.toString());
}
ThreadInfo info = new ThreadInfo(t, mode);
registeredThreads.put(t, info);
// prevent from grantedMode == NONE (another thread - leaveS)
readersNo += 2;
// prevent from new readers
setGrantedMode(CHAIN);
return true;
}
// else X means ERROR!!!
}
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
setGrantedMode(CHAIN);
cell = chain(mode, t, Integer.MAX_VALUE);
waiters.remove(0);
setGrantedMode(mode);
setGrantedMode(NONE);
wakeUpOthers();
代码示例来源:origin: in.jlibs/org-openide-util
setGrantedMode(CHAIN);
cell = chain(mode, t, Integer.MAX_VALUE);
waiters.remove(0);
setGrantedMode(mode);
setGrantedMode(NONE);
wakeUpOthers();
代码示例来源:origin: in.jlibs/org-openide-util
setGrantedMode(S);
} else {
info.mode = NONE;
setGrantedMode(NONE);
registeredThreads.remove(info.t);
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
setGrantedMode(S);
} else {
info.mode = NONE;
setGrantedMode(NONE);
registeredThreads.remove(info.t);
代码示例来源:origin: in.jlibs/org-openide-util
waiters.remove(i--);
qc.wakeMeUp();
setGrantedMode(qc.mode);
setGrantedMode(CHAIN);
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
waiters.remove(i--);
qc.wakeMeUp();
setGrantedMode(qc.mode);
setGrantedMode(CHAIN);
代码示例来源:origin: in.jlibs/org-openide-util
private void wakeUpReaders() {
assert (grantedMode == NONE) || (grantedMode == S);
if (waiters.size() == 0) {
return;
}
for (int i = 0; i < waiters.size(); i++) {
QueueCell qc = waiters.get(i);
synchronized (qc) {
if (qc.isGotOut()) {
// bogus waiter
waiters.remove(i--);
continue;
}
if (qc.mode == S) { // readers only
waiters.remove(i--);
qc.wakeMeUp();
setGrantedMode(S);
if (getThreadInfo(qc.t) == null) {
// force to have a record since recorded threads
// do not use isCompatible call
ThreadInfo ti = new ThreadInfo(qc.t, qc.mode);
ti.forced = true;
readersNo++;
registeredThreads.put(qc.t, ti);
}
}
}
// sync (qc)
}
}
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
private void wakeUpReaders() {
assert (grantedMode == NONE) || (grantedMode == S);
if (waiters.isEmpty()) {
return;
}
for (int i = 0; i < waiters.size(); i++) {
QueueCell qc = waiters.get(i);
synchronized (qc) {
if (qc.isGotOut()) {
// bogus waiter
waiters.remove(i--);
continue;
}
if (qc.mode == S) { // readers only
waiters.remove(i--);
qc.wakeMeUp();
setGrantedMode(S);
if (getThreadInfo(qc.t) == null) {
// force to have a record since recorded threads
// do not use isCompatible call
ThreadInfo ti = new ThreadInfo(qc.t, qc.mode);
ti.forced = true;
readersNo++;
registeredThreads.put(qc.t, ti);
}
}
}
// sync (qc)
}
}
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
info.rsnapshot = info.counts[S];
if (grantedMode == S) {
setGrantedMode(X);
} else if (grantedMode == X) {
setGrantedMode(requested);
registeredThreads.put(t,
info = new ThreadInfo(t, requested));
return false;
setGrantedMode(CHAIN);
cell = chain(requested, t, 0);
代码示例来源:origin: in.jlibs/org-openide-util
setGrantedMode(NONE);
setGrantedMode(X);
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
setGrantedMode(NONE);
setGrantedMode(X);
代码示例来源:origin: in.jlibs/org-openide-util
private boolean reenterImpl(Thread t, int mode) {
// from leaveX -> grantedMode is NONE or S
if (mode == S) {
if ((grantedMode != NONE) && (grantedMode != S)) {
throw new IllegalStateException(this.toString());
}
enter(mode, t, true);
return false;
}
// assert (mode == X)
ThreadInfo tinfo = getThreadInfo(t);
boolean chainFromLeaveX = ((grantedMode == CHAIN) && (tinfo != null) && (tinfo.counts[X] > 0));
// process grantedMode == X or CHAIN from leaveX OR grantedMode == NONE from leaveS
if ((grantedMode == X) || (grantedMode == NONE) || chainFromLeaveX) {
enter(mode, t, true);
return false;
} else { // remains grantedMode == CHAIN or S from leaveS, so it will be CHAIN
if (readersNo == 0) {
throw new IllegalStateException(this.toString());
}
ThreadInfo info = new ThreadInfo(t, mode);
registeredThreads.put(t, info);
// prevent from grantedMode == NONE (another thread - leaveS)
readersNo += 2;
// prevent from new readers
setGrantedMode(CHAIN);
return true;
}
// else X means ERROR!!!
}
代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util
private boolean reenterImpl(Thread t, int mode) {
// from leaveX -> grantedMode is NONE or S
if (mode == S) {
if ((grantedMode != NONE) && (grantedMode != S)) {
throw new IllegalStateException(this.toString());
}
enter(mode, t, true);
return false;
}
// assert (mode == X)
ThreadInfo tinfo = getThreadInfo(t);
boolean chainFromLeaveX = ((grantedMode == CHAIN) && (tinfo != null) && (tinfo.counts[X] > 0));
// process grantedMode == X or CHAIN from leaveX OR grantedMode == NONE from leaveS
if ((grantedMode == X) || (grantedMode == NONE) || chainFromLeaveX) {
enter(mode, t, true);
return false;
} else { // remains grantedMode == CHAIN or S from leaveS, so it will be CHAIN
if (readersNo == 0) {
throw new IllegalStateException(this.toString());
}
ThreadInfo info = new ThreadInfo(t, mode);
registeredThreads.put(t, info);
// prevent from grantedMode == NONE (another thread - leaveS)
readersNo += 2;
// prevent from new readers
setGrantedMode(CHAIN);
return true;
}
// else X means ERROR!!!
}
内容来源于网络,如有侵权,请联系作者删除!