org.openide.util.Mutex.enter()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(145)

本文整理了Java中org.openide.util.Mutex.enter()方法的一些代码示例,展示了Mutex.enter()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mutex.enter()方法的具体详情如下:
包路径:org.openide.util.Mutex
类名称:Mutex
方法名:enter

Mutex.enter介绍

[英]enters this mutex with given mode
[中]以给定模式进入该互斥锁

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-util

/** enters this mutex for reading */
final void readEnter(Thread t) {
  enter(S, t, true);
}

代码示例来源:origin: org.netbeans.api/org-openide-util

/** enters this mutex for writing */
final void writeEnter(Thread t) {
  enter(X, t, true);
}

代码示例来源: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: org.netbeans.api/org-openide-util

enter(mutexMode, t, true);
  } else { // the mutex is held but can not be entered in X mode
    info.enqueue(mutexMode, run);
enter(mutexMode, t, true);
try {
  run.run();

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** enters this mutex for writing */
private void writeEnter(Thread t) {
  enter(X, t, true);
}
/** enters this mutex for reading */

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** enters this mutex for writing */
private void writeEnter(Thread t) {
  enter(X, t, true);
}
/** enters this mutex for reading */

代码示例来源:origin: in.jlibs/org-openide-util

/** enters this mutex for reading */
final void readEnter(Thread t) {
  enter(S, t, true);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

/** enters this mutex for reading */
private void readEnter(Thread t) {
  enter(S, t, true);
}

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

/** enters this mutex for reading */
final void readEnter(Thread t) {
  enter(S, t, true);
}

代码示例来源:origin: in.jlibs/org-openide-util

/** enters this mutex for writing */
final void writeEnter(Thread t) {
  enter(X, t, true);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

/** enters this mutex for reading */
private void readEnter(Thread t) {
  enter(S, t, true);
}

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

/** enters this mutex for writing */
final void writeEnter(Thread t) {
  enter(X, t, true);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

throw new IllegalStateException(this.toString());
  enter(mode, t, true);
  return false;
  enter(mode, t, true);
  return false;
} else { // remains grantedMode == CHAIN or S from leaveS, so it will be CHAIN

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

throw new IllegalStateException(this.toString());
  enter(mode, t, true);
  return false;
  enter(mode, t, true);
  return false;
} else { // remains grantedMode == CHAIN or S from leaveS, so it will be CHAIN

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

enter(mutexMode, t, true);
  } else {  // the mutex is held but can not be entered in X mode
    info.enqueue(mutexMode, run);
enter(mutexMode, t, true);
try {
  run.run();

代码示例来源: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!!!
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

enter(mutexMode, t, true);
  } else {  // the mutex is held but can not be entered in X mode
    info.enqueue(mutexMode, run);
enter(mutexMode, t, true);
try {
  run.run();

代码示例来源:origin: uk.gov.nationalarchives.thirdparty.netbeans/org-openide-util

enter(mutexMode, t, true);
  } else { // the mutex is held but can not be entered in X mode
    info.enqueue(mutexMode, run);
enter(mutexMode, t, true);
try {
  run.run();

代码示例来源:origin: in.jlibs/org-openide-util

enter(mutexMode, t, true);
  } else { // the mutex is held but can not be entered in X mode
    info.enqueue(mutexMode, run);
enter(mutexMode, t, true);
try {
  run.run();

相关文章