当前位置: 首页>>代码示例>>C++>>正文


C++ set_alarm函数代码示例

本文整理汇总了C++中set_alarm函数的典型用法代码示例。如果您正苦于以下问题:C++ set_alarm函数的具体用法?C++ set_alarm怎么用?C++ set_alarm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了set_alarm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: depart

void depart(void)
{
  if(!boatman)
    {
      boatman = make(NMONSTER+"boatman");
    }

  switch(location)
    {
    case 1: tell_room(TO,"The boatman jumps on board and sets sail for "+
                      "Newbie Island.\n");
            tell_room(larstown,"The Boatman jumps into his sailing boat "+
                      "and sets sail for Newbie Island.\n");
      destination = island;
      break;
    case 2: tell_room(TO,"The boatman climbs on board and sets sail for "+
                      "Larstown.\n");
            tell_room(island,"The Boatman pushes the sailing boat out into "+
                      "the shallows, jumps on board, and sets sail for "+
                      "Larstown.\n");
      destination = larstown;
      break;
  }
  transfer(boatman,TO);
  boat_object->destroy();
  set_at_sea();
  set_alarm(5.0 + itof(random(5)),0.0,"journey");
  set_alarm(40.0,0.0,"arrive");
}
开发者ID:yodakingdoms,项目名称:kingdoms,代码行数:29,代码来源:ferry.c

示例2: init

void
init()
{
    ::init();

    set_alarm(0.5, 0.0, &tell_object(this_player(),
        "\nPostmaster is busy burning messages nobody is interested in.\n" +
        "He is not able to handle your mail right now.\n"));
    set_alarm(1.0, 0.0, remove_object);
}
开发者ID:skohlsmith,项目名称:cdlib,代码行数:10,代码来源:mail_no_reader.c

示例3: run_timers

static void
run_timers (void)
{
  EMACS_TIME now;

  EMACS_GET_TIME (now);

  while (atimers
	 && (pending_atimers = interrupt_input_blocked) == 0
	 && EMACS_TIME_LE (atimers->expiration, now))
    {
      struct atimer *t;

      t = atimers;
      atimers = atimers->next;
#ifndef DARWIN_OS
      t->fn (t);
#endif

      if (t->type == ATIMER_CONTINUOUS)
	{
	  EMACS_ADD_TIME (t->expiration, now, t->interval);
	  schedule_atimer (t);
	}
      else
	{
	  t->next = free_atimers;
	  free_atimers = t;
	}
#ifdef DARWIN_OS
      /* Fix for Ctrl-G.  Perhaps this should apply to all platforms. */
      t->fn (t); 
#endif

      EMACS_GET_TIME (now);
    }

  if (! atimers)
    pending_atimers = 0;

#ifdef SYNC_INPUT
  if (pending_atimers)
    pending_signals = 1;
  else
    {
      pending_signals = interrupt_input_pending;
      set_alarm ();
    }
#else
  if (! pending_atimers)
    set_alarm ();
#endif
}
开发者ID:a3090103838,项目名称:emacs-24-mac,代码行数:53,代码来源:atimer.c

示例4: setup_idle

static void setup_idle(void)
{
	uint64_t tsc, pc[NUM_PC_STATES], res, best_res;
	int pc_i, best_pc_i = 0, retries, consecutive_not_best;

	for (retries = 0; ; retries++) {

		set_alarm(opts.res_warm_time, 0);
		while (!alarm_received)
			pause();

		set_alarm(opts.res_calc_time, 0);

		tsc = msr_read(IA32_TIME_STAMP_COUNTER);
		for (pc_i = best_pc_i; pc_i < NUM_PC_STATES; pc_i++)
			pc[pc_i] = msr_read(res_msr_addrs[pc_i]);

		while (!alarm_received)
			pause();

		for (pc_i = best_pc_i; pc_i < NUM_PC_STATES; pc_i++)
			pc[pc_i] = msr_read(res_msr_addrs[pc_i]) - pc[pc_i];
		tsc = msr_read(IA32_TIME_STAMP_COUNTER) - tsc;

		for (pc_i = NUM_PC_STATES -1; pc_i >= best_pc_i; pc_i--)
			if (pc[pc_i] != 0)
				break;
		igt_require_f(pc_i >= 0, "We're not reaching any PC states!\n");

		res = pc[pc_i] * 100 / tsc;

		if (retries == 0 || pc_i > best_pc_i || res > best_res) {
			best_pc_i = pc_i;
			best_res = res;
			consecutive_not_best = 0;
		} else {
			consecutive_not_best++;
			if (consecutive_not_best > 2)
				break;
		}
	}

	deepest_pc_state = res_msr_addrs[best_pc_i];
	idle_res = best_res;

	printf("Stable idle residency retries:\t%d\n", retries);
	printf("Deepest PC state reached when idle:\t%s\n",
	       res_msr_names[best_pc_i]);
	printf("Idle residency for this state:\t%02"PRIu64"%%\n", idle_res);
}
开发者ID:joshloo,项目名称:intel-gpu-tools,代码行数:50,代码来源:intel_residency.c

示例5: do_light

int do_light(string str)
{
    if(str == "fire")
    {
        if(!telling_story)
        {
            if(!TP->test_flag(QUEST_FLAG))
	    {
                W("You light a fire in the fireplace. The old man sighs " +
                  "contentedly as the fire begins to catch and throw " +
                  "strange, long shadows on the walls. 'Now gather round " +
                  "and listen well', he says. 'A tale like this should not " +
                  "be told in too loud a voice. The walls in these parts " +
                  "really do have ears...'\n");
                S(TP->QN + " lights a fire in the fireplace. The old man " +
                  "sighs contentedly and begins the telling of a tale.\n");
                telling_story = 1;
                set_alarm(7.0,0.0,"tell_story",0);
                set_alarm(300.0,0.0,"my_reset");
                return 1;
	    }
            else
            {
                tell_room(ENV(TO),"The storyteller smiles and says: Oh " +
                          "'tis you, " + TP->QN + ". You have already " +
                          "heard my tale. Methinks I will save my voice " +
                          "for some other young adventurer. Godspeed! ");
                W("The storyteller waves happily in your direction.\n");
                S("The storyteller waves happily in " + TP->QN + "'s " +
                  "direction.\n");
                return 1;
	    }
        }
        else if(telling_story == 1)
        {
            W("There is already a fire burning in the fireplace.\n");
            S(TP->QN + " walks over to the fireplace to warm " + TP->QPO +
              " hands.\n");
            return 1;
        }
        else
        {
            W("You try to light a fire but you can't get it started.\n");
            S(TP->QN + " tries to light a fire, but can't get it started.\n");
            return 1;
        }
    }
    return 0;
}
开发者ID:yodakingdoms,项目名称:kingdoms,代码行数:49,代码来源:storyteller.c

示例6: _user_set_alarm

bigtime_t
_user_set_alarm(bigtime_t time, uint32 mode)
{
	syscall_64_bit_return_value();

	return set_alarm(time, mode);
}
开发者ID:mmanley,项目名称:Antares,代码行数:7,代码来源:signal.cpp

示例7: run_timers

static void
run_timers (void)
{
  EMACS_TIME now = current_emacs_time ();

  while (atimers && EMACS_TIME_LE (atimers->expiration, now))
    {
      struct atimer *t = atimers;
      atimers = atimers->next;
      t->fn (t);

      if (t->type == ATIMER_CONTINUOUS)
	{
	  t->expiration = add_emacs_time (now, t->interval);
	  schedule_atimer (t);
	}
      else
	{
	  t->next = free_atimers;
	  free_atimers = t;
	}
    }

  set_alarm ();
}
开发者ID:betusgarcon,项目名称:emacs,代码行数:25,代码来源:atimer.c

示例8: charger_bat_alarm

static void charger_bat_alarm(struct alarm *alarm)
{
	struct max77665_charger *chg = container_of(alarm, struct max77665_charger, alarm);

	wake_lock_timeout(&chg->wake_lock, 3 * HZ);
	set_alarm(chg, WAKE_ALARM_INT);
}
开发者ID:Abioy,项目名称:meizu-mx-kernel,代码行数:7,代码来源:max77665_charger.c

示例9: arrive

void arrive(void)
{
  if(destination == larstown)
  {
    tell_room(larstown,"A small sailing boat arrives at "+
              "the pier. The boatman climbs ashore after "+
              "furling the sails.\n");
    tell_room(TO,"The boat finally glides into the calmer waters inside "+
              "the Larstown harbour breakwater. The boatman steers it "+
              "to the pier, and jumps ashore to tie the lines to something "+
              "secure.\n");
    transfer(boatman,larstown);
    set_at_lars();
  }
  if(destination == island)
  {
    tell_room(island,"A small sailing boat arrives at the "+
              "shore. The boatman jumps ashore and pulls "+
              "the boat safely up onto the sand.\n");
    tell_room(TO,"The boat finally glides into calmer waters as it gets "+
              "close to the island. The Boatman jumps into the shallow water "+
              "and pulls the boat ashore.\n");
    transfer(boatman,island);
    set_at_island();
  }
  set_alarm(40.0,0.0,"depart");
}
开发者ID:yodakingdoms,项目名称:kingdoms,代码行数:27,代码来源:ferry.c

示例10: gtthread_init

/*
  The gtthread_init() function does not have a corresponding pthread equivalent.
  It must be called from the main thread before any other GTThreads
  functions are called. It allows the caller to specify the scheduling
  period (quantum in micro second), and may also perform any other
  necessary initialization.  If period is zero, then thread switching should
  occur only on calls to gtthread_yield().

  Recall that the initial thread of the program (i.e. the one running
  main() ) is a thread like any other. It should have a
  gtthread_t that clients can retrieve by calling gtthread_self()
  from the initial thread, and they should be able to specify it as an
  argument to other GTThreads functions. The only difference in the
  initial thread is how it behaves when it executes a return
  instruction. You can find details on this difference in the man page
  for pthread_create.
 */
void gtthread_init(long period){
  gtthread_t main_id = tid++;

  q = (steque_t*)malloc(sizeof(steque_t));
  steque_init(q);

  void* main_item;
  main_item = (node_t*)malloc(sizeof(node_t));
  ((node_t*)main_item) -> thread_ctx =  (ucontext_t*)malloc(sizeof(ucontext_t));
  ((node_t*)main_item) -> id = main_id;
  getcontext(((node_t*)main_item) -> thread_ctx);
  //TODO: need to init context?

  steque_enqueue(q, main_item);

  /*
    Setting up the signal mask
  */
  sigemptyset(&vtalrm);
  sigaddset(&vtalrm, SIGVTALRM);
  sigprocmask(SIG_UNBLOCK, &vtalrm, NULL);

  T = (struct itimerval*) malloc(sizeof(struct itimerval));
  p = period;

  set_alarm();
}
开发者ID:priyankaganesan,项目名称:GTThreads,代码行数:44,代码来源:gtthread_sched.c

示例11: run_timers

static void
run_timers (void)
{
  struct timespec now = current_timespec ();

  while (atimers && timespec_cmp (atimers->expiration, now) <= 0)
    {
      struct atimer *t = atimers;
      atimers = atimers->next;
      t->fn (t);

      if (t->type == ATIMER_CONTINUOUS)
	{
	  t->expiration = timespec_add (now, t->interval);
	  schedule_atimer (t);
	}
      else
	{
	  t->next = free_atimers;
	  free_atimers = t;
	}
    }

  set_alarm ();
}
开发者ID:0230,项目名称:deepin-emacs,代码行数:25,代码来源:atimer.c

示例12: do_light

int do_light(string str)
{
    int sp_cost = 10 + random(10);

    if(str == "stone" && TP->QS("attune") > 20 && ENV(TO) == TP)
    {
        if(shining)
        {
            W("The stone is already shining!\n");
            return 1;
        }

        if(TP->query_spell_points() >= sp_cost)
        {
            W("You channel some power into the stone and make it shine "+
              "with a warm light.\n");
            S(TP->QN + " concentrates on a small stone and suddenly it "+
              "starts shining with a warm light.\n");
            TP->reduce_spell_points(sp_cost);
            user = TP;
            light();
            set_alarm(300.0 + itof(random(120)),0.0,"drain");
        }
        else
        {
            W("You don't have enough power to light the stone at the "+
              "moment.\n");
            S(TP->QN + " concentrates on a small stone but looks "+
              "disappointed.\n");
            return 1;
        }
    }
    // No mistake here. Don't want hints to people with attune < 20,
    // and don't want to mess up other light commands
}
开发者ID:yodakingdoms,项目名称:kingdoms,代码行数:35,代码来源:lightstone.c

示例13: drain

void drain(void)
{
    int sp_drain = random(5) + 1;

    if(shining)
    {
        if(ENV(TO) != user)
        {
            tell_object(ENV(TO),"The stone stops shining.\n");
            darken();
            return;
        }

        if(sp_drain > user->query_spell_points())
        {
            tell_object(user,"The stone grows dark as you have no more "+
                        "power to channel into it.\n");
            darken();
            return;
        }

        tell_object(user,"You channel some power into the stone to keep "+
                    "it shining.\n");
        user->reduce_spell_points(sp_drain);
        set_alarm(300.0 + itof(random(120)),0.0,"drain");
    }
}
开发者ID:yodakingdoms,项目名称:kingdoms,代码行数:27,代码来源:lightstone.c

示例14: wait_until_idle

static void wait_until_idle(void)
{
	uint64_t tsc, pc, res;

	do {
		set_alarm(0, 500 * 1000);

		tsc = msr_read(IA32_TIME_STAMP_COUNTER);
		pc = msr_read(deepest_pc_state);

		while (!alarm_received)
			pause();

		pc = msr_read(deepest_pc_state) - pc;
		tsc = msr_read(IA32_TIME_STAMP_COUNTER) - tsc;

		res = pc * 100 / tsc;

		/*printf("res:%02"PRIu64"\n", res);*/
	} while (res < idle_res && idle_res - res > 3);

	if (res > idle_res && res - idle_res > 3)
		fprintf(stderr, "The calculated idle residency may be too low "
			"(got %02"PRIu64"%%)\n", res);
}
开发者ID:joshloo,项目名称:intel-gpu-tools,代码行数:25,代码来源:intel_residency.c

示例15: turn_on_atimers

void
turn_on_atimers (bool on)
{
  if (on)
    set_alarm ();
  else
    alarm (0);
}
开发者ID:0230,项目名称:deepin-emacs,代码行数:8,代码来源:atimer.c


注:本文中的set_alarm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。