code: boolean takeWorkPermit(boolean takeTaskPermit)
      {
          int taskDelta = takeTaskPermit ? 1 : 0;
          while (true)
          {
              long current = permits.get();
              int workPermits = workPermits(current);
              int taskPermits = taskPermits(current);
              if (workPermits == 0 || taskPermits == 0)
                  return false;
              if (permits.compareAndSet(current, combine(taskPermits - taskDelta, workPermits - 1)))
              {
                  if (takeTaskPermit && taskPermits == maxTasksQueued && hasRoom.hasWaiters())
                      hasRoom.signalAll();
                  return true;
              }
          }
      }
docs: takes a worker permit and (optionally) a task permit simultaneously; if one of the two is unavailable, returns false