public void exitWriteAccess() { parent.leave(Thread.currentThread()); } }
leave(t); // release lock grabbed - shared
public void exitReadAccess() { parent.leave(Thread.currentThread()); }
/** Run an action with read access, returning no result. * It may be run asynchronously. * * @param action the action to perform * @see #readAccess(Mutex.Action) */ public void readAccess(final Runnable action) { if (this == EVENT) { doEvent(action); return; } if (wrapper != null) { try { doWrapperAccess(null, action, true); return; } catch (MutexException ex) { throw new IllegalStateException(ex); } } Thread t = Thread.currentThread(); readEnter(t); try { action.run(); } finally { leave(t); } }
/** Run an action with write access and return no result. * It may be run asynchronously. * * @param action the action to perform * @see #writeAccess(Mutex.Action) * @see #readAccess(Runnable) */ public void writeAccess(final Runnable action) { if (this == EVENT) { doEvent(action); return; } if (wrapper != null) { try { doWrapperAccess(null, action, false); } catch (MutexException ex) { throw new IllegalStateException(ex); } return; } Thread t = Thread.currentThread(); writeEnter(t); try { action.run(); } finally { leave(t); } }
/** Run an action only with read access. * See class description re. entering for write access within the dynamic scope. * @param action the action to perform * @return the object returned from {@link Mutex.Action#run} */ public <T> T readAccess(final Action<T> action) { if (this == EVENT) { try { return doEventAccess(action); } catch (MutexException e) { throw (InternalError) new InternalError("Exception from non-Exception Action").initCause(e.getException()); // NOI18N } } if (wrapper != null) { try { return doWrapperAccess(action, null, true); } catch (MutexException e) { throw (InternalError) new InternalError("Exception from non-Exception Action").initCause(e.getException()); // NOI18N } } Thread t = Thread.currentThread(); readEnter(t); try { return action.run(); } finally { leave(t); } }
/** Run an action with write access. * The same thread may meanwhile reenter the mutex; see the class description for details. * * @param action the action to perform * @return the result of {@link Mutex.Action#run} */ public <T> T writeAccess(Action<T> action) { if (this == EVENT) { try { return doEventAccess(action); } catch (MutexException e) { throw (InternalError) new InternalError("Exception from non-Exception Action").initCause(e.getException()); // NOI18N } } if (wrapper != null) { try { return doWrapperAccess(action, null, false); } catch (MutexException e) { throw (InternalError) new InternalError("Exception from non-Exception Action").initCause(e.getException()); // NOI18N } } Thread t = Thread.currentThread(); writeEnter(t); try { return action.run(); } finally { leave(t); } }
throw new MutexException(e); } finally { leave(t);
throw new MutexException(e); } finally { leave(t);
public void exitWriteAccess() { parent.leave(Thread.currentThread()); } }
public void exitWriteAccess() { parent.leave(Thread.currentThread()); } }
public void exitReadAccess() { parent.leave(Thread.currentThread()); }
public void exitReadAccess() { parent.leave(Thread.currentThread()); }
/** Run an action with read access, returning no result. * It may be run asynchronously. * * @param action the action to perform * @see #readAccess(Mutex.Action) */ public void readAccess (final Runnable action) { if (this == EVENT) { doEvent (action); return; } Thread t = Thread.currentThread(); readEnter(t); try { action.run(); } finally { leave(t); } }
/** Run an action with read access, returning no result. * It may be run asynchronously. * * @param action the action to perform * @see #readAccess(Mutex.Action) */ public void readAccess (final Runnable action) { if (this == EVENT) { doEvent (action); return; } Thread t = Thread.currentThread(); readEnter(t); try { action.run(); } finally { leave(t); } }
/** Run an action with write access and return no result. * It may be run asynchronously. * * @param action the action to perform * @see #writeAccess(Mutex.Action) * @see #readAccess(Runnable) */ public void writeAccess (final Runnable action) { if (this == EVENT) { doEvent (action); return; } Thread t = Thread.currentThread(); writeEnter(t); try { action.run(); } finally { leave(t); } }
/** Run an action with write access and return no result. * It may be run asynchronously. * * @param action the action to perform * @see #writeAccess(Mutex.Action) * @see #readAccess(Runnable) */ public void writeAccess (final Runnable action) { if (this == EVENT) { doEvent (action); return; } Thread t = Thread.currentThread(); writeEnter(t); try { action.run(); } finally { leave(t); } }
/** Run an action only with read access. * See class description re. entering for write access within the dynamic scope. * @param action the action to perform * @return the object returned from {@link Mutex.Action#run} */ public Object readAccess (Action action) { if (this == EVENT) { try { return doEventAccess (action); } catch (MutexException e) { InternalError err = new InternalError("Exception from non-Exception Action"); // NOI18N ErrorManager.getDefault().annotate(err, e.getException()); throw err; } } Thread t = Thread.currentThread(); readEnter(t); try { return action.run(); } finally { leave(t); } }
/** Run an action only with read access. * See class description re. entering for write access within the dynamic scope. * @param action the action to perform * @return the object returned from {@link Mutex.Action#run} */ public Object readAccess (Action action) { if (this == EVENT) { try { return doEventAccess (action); } catch (MutexException e) { InternalError err = new InternalError("Exception from non-Exception Action"); // NOI18N ErrorManager.getDefault().annotate(err, e.getException()); throw err; } } Thread t = Thread.currentThread(); readEnter(t); try { return action.run(); } finally { leave(t); } }