src/concurrent/dotnet/ThreadPool.cs
/// <summary>
/// This is called by a worker when it completes a work item.
/// If there is pending work return it.  Otherwise if idle time
/// is over then free the worker and let it die. If idle time is
/// not over then put the worker into our idle queue.
/// </summary>
This is called by a worker when it completes a work item.
If there is pending work return it.  Otherwise if idle time
is over then free the worker and let it die. If idle time is
not over then put the worker into our idle queue.
This is called by a worker when it completes a work item . If there is pending work return it . Otherwise if idle time is over then free the worker and let it die . If idle time is not over then put the worker into our idle queue .
[MethodImpl(MethodImplOptions.Synchronized)]
    internal Work ready(Worker w, bool idleTimeOver)
    {
      LinkedListNode<Work> node = pending.First;
      if (node != null)
      {
        pending.RemoveFirst();
        return node.Value;
      }
      if (idleTimeOver || state != RUNNING)
      {
        free(w);
        return null;
      }
      idle.AddFirst(w);
      return null;
    }
[ MethodImpl ( MethodImplOptions . Synchronized ) ] internal Work ready ( Worker w , bool idleTimeOver ) { LinkedListNode < Work > node = pending . First ; if ( node != null ) { pending . RemoveFirst ( ) ; return node . Value ; } if ( idleTimeOver || state != RUNNING ) { free ( w ) ; return null ; } idle . AddFirst ( w ) ; return null ; }
This is called by a worker when it completes a work item.
This is called by a worker when it completes a work item .
// if we have a pending work, then immediately reuse the worker // if the worker's idle time is over or we are // shutting down, then free the worker and let it die // add to head of idle list (we let oldest threads die out first)
w
Worker
idleTimeOver
bool