Agents will try to enter. The pub checks if it is possible
494597
def enter(self, pub_id, *nodes):
        ''''''
        try:
            pub = self['pubs'][pub_id]
        except KeyError:
            raise ValueError('Pub {} is not available'.format(pub_id))
        if not pub['open'] or (pub['capacity'] < (len(nodes) + pub['occupancy'])):
            return False
        pub['occupancy'] += len(nodes)
        for node in nodes:
            node['pub'] = pub_id
        return True
923030
protected Object checkUserAgent(ServerUserHandlerClass handler, ApiUser userAgent) {
        if(handler.getUserClass().isAssignableFrom(userAgent.getClass()))
            return userAgent;
        return UserAgentUtil.getGameUser(userAgent, handler.getUserClass());
    }
533873
function Agent(consul) {
  this.consul = consul;
  this.check = new Agent.Check(consul);
  this.service = new Agent.Service(consul);
}
523865
def ensure(user, action, subject):
    
    ability = Ability(user, get_authorization_method())
    if ability.cannot(action, subject):
        raise AccessDenied()
1332606
def _Execute(self, options):
        """"""
        whitelist = dict(
            name=options["name"],
            description=options.get("description", "<empty>"))
        return self._agent.client.compute.security_groups.create(**whitelist)
1062087
private final void offerEntry(ChartEntry entry, double probability, int spanStart, int spanEnd) {
    int nextEntryIndex = chartSizes[spanStart][spanEnd];
    if (nextEntryIndex == chart[spanStart][spanEnd].length) {
      // Resize the arrays to fit the new entry.
      ChartEntry[] spanChart = chart[spanStart][spanEnd];
      double[] spanProbs = probabilities[spanStart][spanEnd];
      chart[spanStart][spanEnd] = Arrays.copyOf(spanChart, spanChart.length * 2);
      probabilities[spanStart][spanEnd] = Arrays.copyOf(spanProbs, spanChart.length * 2);
    }

    chart[spanStart][spanEnd][nextEntryIndex] = entry;
    probabilities[spanStart][spanEnd][nextEntryIndex] = probability;
    chartSizes[spanStart][spanEnd]++;
    totalChartSize++;
  }
564657
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;
            }
        }
    }
231105
function can (action, target) {
    return check(this.auth.credentials && this.auth.credentials.user, action, target)
  }
143747
function posBar(_pos) {
            if (this.bar) {
                var was = css(this.bar, this.origin.pos),
                    will = +_pos + 'px'

                if (will && will != was) {
                    css(this.bar, this.origin.pos, will)
                }
            }
        }
1250050
private void onMiss(long key) {
    Node node = new Node(key, Status.WINDOW_PROBATION);
    node.appendToTail(headWindowProbation);
    data.put(key, node);
    sizeWindow++;
    evict();
  }
25139
private final void offerEntry(ChartEntry entry, double probability, int spanStart, int spanEnd) {
    HeapUtils.offer(chart[spanStart][spanEnd], probabilities[spanStart][spanEnd],
        chartSizes[spanEnd + (numTerminals * spanStart)], entry, probability);
    chartSizes[spanEnd + (numTerminals * spanStart)]++;
    totalChartSize++;

    if (chartSizes[spanEnd + (numTerminals * spanStart)] > beamSize) {
      HeapUtils.removeMin(chart[spanStart][spanEnd], probabilities[spanStart][spanEnd],
          chartSizes[spanEnd + (numTerminals * spanStart)]);
      chartSizes[spanEnd + (numTerminals * spanStart)]--;
      totalChartSize--;
    }
  }
256783
function runPrompt (opts, cb) {
  prompt([
    {
      name: 'name',
      message: 'Package name',
      default: opts.packageName || ''
    },
    {
      name: 'description',
      message: 'Module description'
    },
    {
      name: 'tags',
      message: 'Module tags'
    }
  ], cb)
}
965874
@Override
    public boolean simpleEvaluation(Agent agent) {
        Node device = agent.getAgentsAppState().getDevicesAppState().getDevice(deviceId);
        if (device != null) {
            PHATDoorSensor psControl = device.getControl(PHATDoorSensor.class);
            if (psControl != null) {
                DoorData doorData = psControl.getDoorData();
                if(doorData != null) {
                    return (doorState.equals("ON") && psControl.getDoorData().isOpened()) ||
                            (doorState.equals("OFF") && !psControl.getDoorData().isOpened());
                }
            }
        }
        return false;
    }
365868
def matching_pubkey
      Pubkey.all
        .detect { |key| key.verify(self) }
        .tap { |key| self.pubkey = key }
    end
726370
private void onMiss(long key) {
    for (int i = 0; i < gain; i++) {
      admittor.record(key);
    }

    Node node = new Node(key);
    node.appendToTail(head);
    data.put(key, node);
    evict(node);
  }
1059512
private void validate() {
        long delayedEventCount = delayedEvents.size();

        long outstandingAgents = config.agents - agentsAvailable.size();
        long outstandingPhones = config.numbers - phoneNumbersAvailable.size();

        if (outstandingAgents != outstandingPhones) {
            throw new RuntimeException(
                    String.format("outstandingAgents (%d) != outstandingPhones (%d)",
                            outstandingAgents, outstandingPhones));
        }
        if (outstandingAgents != delayedEventCount) {
            throw new RuntimeException(
                    String.format("outstandingAgents (%d) != delayedEventCount (%d)",
                            outstandingAgents, delayedEventCount));
        }
    }
420533
function processWaitingPublishPromises( self, newPromiseResolves ) {
   const waitingResolves = self.waitingPromiseResolves_;
   self.waitingPromiseResolves_ = newPromiseResolves;

   waitingResolves.forEach( resolve => resolve() );

   if( self.eventQueue_.length === 0 ) {
      // nothing was queued by any subscriber. The publishers can instantly be notified of delivery.
      newPromiseResolves.forEach( resolve => resolve() );
      self.waitingPromiseResolves_ = [];
   }
}