Tabnine Logo
ForkJoinPool.managedBlock
Code IndexAdd Tabnine to your IDE (free)

How to use
managedBlock
method
in
jsr166y.ForkJoinPool

Best Java code snippets using jsr166y.ForkJoinPool.managedBlock (Showing top 8 results out of 315)

origin: h2oai/h2o-2

/** Block for and get any final results from a dfork'd MRTask2.
 *  Note: the desired name 'get' is final in ForkJoinTask.  */
public final T getResult() {
 try {
  try {
   ForkJoinPool.managedBlock(this);
  } catch (InterruptedException e) {
  }
  return self();
 }catch(Throwable t){
  throw new RuntimeException(t);
 }
}
origin: h2oai/h2o-2

/** Block this thread until all prior remote PUTs complete - to force
 *  remote-PUT ordering on the home node. */
void startRemotePut() {
 assert !_key.home();
 int x = 0;
 // assert I am waiting on threads with higher priority?
 while( (x=_rwlock.get()) != -1 ) // Spin until rwlock==-1
  if( x == 1 || RW_CAS(0,1,"remote_need_notify") )
   try { ForkJoinPool.managedBlock(this); } catch( InterruptedException e ) { }
}
origin: h2oai/h2o-2

public static void reserveTaskMem(long m){
 final long bytes = m;
 while(!tryReserveTaskMem(bytes)){
  try {
   ForkJoinPool.managedBlock(new ManagedBlocker() {
    @Override
    public boolean isReleasable() {return _taskMem.get() >= bytes;}
    @Override
    public boolean block() throws InterruptedException {
     synchronized(_taskMemLock){
      try {_taskMemLock.wait();} catch( InterruptedException e ) {}
     }
     return isReleasable();
    }
   });
  } catch (InterruptedException e){throw  Log.errRTExcept(e); }
 }
}
origin: h2oai/h2o-2

public T invoke( Key... keys ) {
 try {
  ForkJoinPool.managedBlock(dfork(keys));
 } catch(InterruptedException  iex) { Log.errRTExcept(iex); }
 // Intent was to quietlyJoin();
 // Which forks, then QUIETLY join to not propagate local exceptions out.
 return self();
}
origin: h2oai/h2o-2

@Override public V get() {
 // check priorities - FJ task can only block on a task with higher priority!
 Thread cThr = Thread.currentThread();
 int priority = (cThr instanceof FJWThr) ? ((FJWThr)cThr)._priority : -1;
 // was hitting this (priority=1 but _dt.priority()=0 for DRemoteTask) - not clear who increased priority of FJWThr to 1...
 // assert _dt.priority() > priority || (_dt.priority() == priority && (_dt instanceof DRemoteTask || _dt instanceof MRTask2))
 assert _dt.priority() > priority || ((_dt instanceof DRemoteTask || _dt instanceof MRTask2))
  : "*** Attempting to block on task (" + _dt.getClass() + ") with equal or lower priority. Can lead to deadlock! " + _dt.priority() + " <=  " + priority;
 if( _done ) return result(); // Fast-path shortcut
 // Use FJP ManagedBlock for this blocking-wait - so the FJP can spawn
 // another thread if needed.
 try {
  try {
   ForkJoinPool.managedBlock(this);
  } catch (InterruptedException e) {
  }
 } catch(Throwable t){
  // catch and rethrow to preserve the stack trace!
  throw new RuntimeException(t);
 }
 if( _done ) return result(); // Fast-path shortcut
 assert isCancelled();
 return null;
}
// Return true if blocking is unnecessary, which is true if the Task isDone.
origin: h2oai/h2o-2

  ForkJoinPool.managedBlock(node);
} catch (InterruptedException ie) {
  node.wasInterrupted = true;
origin: h2oai/h2o-2

/** This value was atomically extracted from the local STORE by a successful
 *  TaskPutKey attempt (only 1 thread can ever extract and thus call here).
 *  No future lookups will find this Value, but there may be existing uses.
 *  Atomically set the rwlock count to -1 locking it from further GETs and
 *  ship out invalidates to caching replicas.  May need to block on active
 *  GETs.  Updates a set of Future invalidates that can be blocked against. */
Futures lockAndInvalidate( H2ONode sender, Futures fs ) {
 assert _key.home(); // Only the HOME node for a key tracks replicas
 // Write-Lock against further GETs
 while( true ) {      // Repeat, in case racing GETs are bumping the counter
  int old = _rwlock.get();
  assert old >= 0 : _key+", rwlock="+old;  // Count does not go negative
  assert old != -1; // Only the thread doing a PUT ever locks
  if( old !=0 ) { // has readers?
   // Active readers: need to block until the GETs (of this very Value!)
   // all complete, before we can invalidate this Value - lest a racing
   // Invalidate bypass a GET.
   try { ForkJoinPool.managedBlock(this); } catch( InterruptedException e ) { }
  } else if( RW_CAS(0,-1,"wlock") )
   break;                  // Got the write-lock!
 }
 // We have the set of Nodes with replicas now.  Ship out invalidates.
 int max = _replicas.length();
 for( int i=0; i<max; i++ )
  if( _replicas.contains(i) && H2ONode.IDX[i] != sender )
   TaskInvalidateKey.invalidate(H2ONode.IDX[i],_key,fs);
 return fs;
}
origin: org.codehaus.jsr166-mirror/jsr166y

  ForkJoinPool.managedBlock(node);
} catch (InterruptedException ie) {
  node.wasInterrupted = true;
jsr166yForkJoinPoolmanagedBlock

Javadoc

Blocks in accord with the given blocker. If the current thread is a ForkJoinWorkerThread, this method possibly arranges for a spare thread to be activated if necessary to ensure sufficient parallelism while the current thread is blocked.

If the caller is not a ForkJoinTask, this method is behaviorally equivalent to

  
while (!blocker.isReleasable())
If the caller is a ForkJoinTask, then the pool may first be expanded to ensure parallelism, and later adjusted.

Popular methods of ForkJoinPool

  • invoke
    Performs the given task, returning its result upon completion. If the computation encounters an unch
  • <init>
    Creates a ForkJoinPool with the given parameters.
  • execute
    Arranges for (asynchronous) execution of the given task.
  • addWorker
    Tries to create and start a worker; minimally rolls back counts on failure.
  • checkPermission
    If there is a security manager, makes sure caller has permission to modify threads.
  • deregisterWorker
    Final callback from terminating worker. Removes record of worker from array, and adjusts counts. If
  • getParallelism
    Returns the targeted parallelism level of this pool.
  • getPoolSize
    Returns the number of worker threads that have started but not yet terminated. The result returned b
  • idleAwaitWork
    If inactivating worker w has caused pool to become quiescent, check for pool termination, and wait f
  • idlePerActive
    Returns the approximate (non-atomic) number of idle threads per active thread.
  • isTerminated
    Returns true if all tasks have completed following shut down.
  • nextWorkerName
    Callback from ForkJoinWorkerThread constructor to assign a public name
  • isTerminated,
  • nextWorkerName,
  • registerWorker,
  • scan,
  • signalWork,
  • tryTerminate,
  • addActiveCount,
  • addQuiescerCount,
  • addSubmission

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • getExternalFilesDir (Context)
  • findViewById (Activity)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now