コード例 #1
0
ファイル: cycle.c プロジェクト: pap/ponyc
static void deferred(pony_ctx_t* ctx, detector_t* d)
{
  if(d->since_deferred < d->next_deferred)
    return;

  d->attempted++;

  bool found = false;
  size_t i = HASHMAP_BEGIN;
  view_t* view;

  while((view = viewmap_next(&d->deferred, &i)) != NULL)
  {
    assert(view->deferred == true);
    viewmap_removeindex(&d->deferred, i);
    view->deferred = false;

    if(!detect(ctx, d, view))
      break;

    found = true;
  }

  if(found)
  {
    if(d->next_deferred > d->min_deferred)
      d->next_deferred >>= 1;
  } else {
    if(d->next_deferred < d->max_deferred)
コード例 #2
0
ファイル: cycle.c プロジェクト: cosinuz/ponyc
static void send_conf(pony_ctx_t* ctx, detector_t* d, perceived_t* per)
{
  size_t i = per->last_conf;
  size_t count = 0;
  view_t* view;

  while((view = viewmap_next(&per->map, &i)) != NULL)
  {
    pony_sendi(ctx, view->actor, ACTORMSG_CONF, per->token);
    count++;

    if(count == d->conf_group)
      break;
  }

  per->last_conf = i;
}