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


C++ reschedule函数代码示例

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


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

示例1: while

	void simple_scheduler::thread_proc(int id) {
		try {
			schedule_queue_type::value_type instance;
			while (!stop_requested_) {
				instance = queue_.pop();
				if (!instance) {
					boost::unique_lock<boost::mutex> lock(idle_thread_mutex_);
					idle_thread_cond_.wait(lock);
					continue;
				}

				try {
					boost::posix_time::time_duration off = now() - (*instance).time;
					if (off.total_seconds() > error_threshold_) {
						log_error("Ran scheduled item " + strEx::s::xtos(instance->schedule_id) + " " + strEx::s::xtos(off.total_seconds()) + " seconds to late from thread " + strEx::s::xtos(id));
					}
					boost::thread::sleep((*instance).time);
				} catch (boost::thread_interrupted  &e) {
					if (!queue_.push(*instance))
						log_error("ERROR");
					if (stop_requested_) {
						log_error("Terminating thread: " + strEx::s::xtos(id));
						return;
					}
					continue;
				} catch (...) {
					if (!queue_.push(*instance))
						log_error("ERROR");
					continue;
				}

				boost::posix_time::ptime now_time = now();
				boost::optional<schedules::schedule_object> item = get_task((*instance).schedule_id);
				if (item) {
					try {
						if (handler_)
							handler_->handle_schedule(*item);
						reschedule(*item,now_time);
					} catch (...) {
						log_error("UNKNOWN ERROR RUNING TASK: ");
						reschedule(*item);
					}
				} else {
					log_error("Task not found: " + strEx::s::xtos(instance->schedule_id));
				}
			}
		} catch (const std::exception &e) {
			log_error("Exception in scheduler thread (thread will be killed): " + utf8::utf8_from_native(e.what()));
		} catch (...) {
			log_error("Exception in scheduler thread (thread will be killed)");
		}

	}
开发者ID:lazyfrosch,项目名称:nscp,代码行数:53,代码来源:simple_scheduler.cpp

示例2: qWarning

void Courier::setForwardRescheduleSignal(QObject &ob, bool fwd)
{
	if(fwd) {
		if(!connect(&ob,SIGNAL(reschedule(quint64)),this,SIGNAL(reschedule(quint64)),OC_CONTYPE)) {
			qWarning()<<"ERROR: Could not connect "<<ob.objectName();
		}
	} else {
		if(!disconnect(&ob,SIGNAL(reschedule(quint64)),this,SIGNAL(reschedule(quint64)))) {
			qWarning()<<"ERROR: Could not disconnect "<<ob.objectName();
		}
	}
}
开发者ID:mrdeveloperdude,项目名称:OctoMY,代码行数:12,代码来源:Courier.cpp

示例3: get_current_thread

char *resolve_name(int serviceid)
{
	struct directory_resolvename res_cmd;
	struct directory_response dir_res;
	char *service_name = "";
	int id_proc;

	res_cmd.command = DIRECTORY_RESOLVENAME;
	res_cmd.serviceid = serviceid;
 	res_cmd.ret_port = dirlib_port;
	res_cmd.thr_id = get_current_thread();
	// we will send an smo with size 1 first
	// servicename will not fit and directory will return
	// an error spacifying dir name size.
	res_cmd.name_smo = share_mem(DIRECTORY_TASK, service_name, 1, WRITE_PERM); 
	
	send_msg(DIRECTORY_TASK, DIRECTORY_PORT, &res_cmd);
  
	while (get_msg_count(dirlib_port) == 0) { reschedule(); }

	get_msg(dirlib_port, &dir_res, &id_proc);

	claim_mem(res_cmd.name_smo);	

	if(dir_res.ret == DIRECTORYERR_SMO_TOOSMALL)
	{
		// now malloc for servicename
		service_name = (char *)malloc(dir_res.ret_value + 1);

		res_cmd.name_smo = share_mem(DIRECTORY_TASK, service_name, len(service_name) + 1, WRITE_PERM); 

		send_msg(DIRECTORY_TASK, DIRECTORY_PORT, &res_cmd);
  
		while (get_msg_count(dirlib_port) == 0) { reschedule(); }

		get_msg(dirlib_port, &dir_res, &id_proc);

		claim_mem(res_cmd.name_smo);	

		if(dir_res.ret != DIRECTORYERR_OK) 
		{
			free(service_name);
			return NULL; // fail
		}

		return service_name;
	}
	else
	{
		return NULL; // fail
	}
}
开发者ID:ahamid,项目名称:sartoris,代码行数:52,代码来源:dirlib.c

示例4: change_task_priority

/*
 * Change task priority.
 */
EXPORT void change_task_priority( TCB *tcb, INT priority )
{
	INT	oldpri;

	if ( tcb->state == TS_READY ) {
		/*
		 * When deleting a task from the ready queue,
		 * a value in the 'priority' field in TCB is needed.
		 * Therefore you need to delete the task from the
		 * ready queue before changing 'tcb->priority.'
		 */
		ready_queue_delete(&ready_queue, tcb);
		tcb->priority = (UB)priority;
		ready_queue_insert(&ready_queue, tcb);
		reschedule();
	} else {
		oldpri = tcb->priority;
		tcb->priority = (UB)priority;

		/* If the hook routine at the task priority change is defined,
		   execute it */
		if ( (tcb->state & TS_WAIT) != 0 && tcb->wspec->chg_pri_hook) {
			(*tcb->wspec->chg_pri_hook)(tcb, oldpri);
		}
	}
}
开发者ID:Ninals-GitHub,项目名称:TRON,代码行数:29,代码来源:task.c

示例5: operator

                        virtual void operator() ()
                        {
                                m_dht.restore();
                                m_dht.maintain();

                                reschedule();
                        }
开发者ID:0vermind,项目名称:libcage,代码行数:7,代码来源:dht.hpp

示例6: ser_base_async

void
ser_base_async (struct serial *scb,
		int async_p)
{
  if (async_p)
    {
      /* Force a re-schedule.  */
      scb->async_state = NOTHING_SCHEDULED;
      if (serial_debug_p (scb))
	fprintf_unfiltered (gdb_stdlog, "[fd%d->asynchronous]\n",
			    scb->fd);
      reschedule (scb);
    }
  else
    {
      if (serial_debug_p (scb))
	fprintf_unfiltered (gdb_stdlog, "[fd%d->synchronous]\n",
			    scb->fd);
      /* De-schedule whatever tasks are currently scheduled.  */
      switch (scb->async_state)
	{
	case FD_SCHEDULED:
	  delete_file_handler (scb->fd);
	  break;
	case NOTHING_SCHEDULED:
	  break;
	default: /* TIMER SCHEDULED */
	  delete_timer (scb->async_state);
	  break;
	}
    }
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:32,代码来源:ser-base.c

示例7: block_thread

/* block_thread() & preempt_thread() */
void block_thread(void)
{
    cthread->state = THREAD_BLOCKED;
    memcpy((void *) &cthread->ctx, (void *) __ctx, sizeof(struct sys_context)); /* save threads context */
    reschedule();
    return;
}
开发者ID:kylelutz,项目名称:link-os,代码行数:8,代码来源:thread.c

示例8: reschedule

    void Monotonic::Manager::start(Monotonic *timer)
    {
      if(timer == nullptr)
      {
        throw;
      }

      bool added = false;

      for(auto i = timers.begin(); i != timers.end(); ++i)
      {
        Monotonic *current = *i;

        if(current->time + current->offset > timer->time + timer->offset)
        {
          timers.insert(i, timer);
          added = true;
          break;
        }
      }

      if(!added)
      {
        timers.push_back(timer);
      }

      Watcher::start();
      reschedule();
    }
开发者ID:Overkiz,项目名称:libcore,代码行数:29,代码来源:Timer.cpp

示例9: timer_callback

// Warning: this function is called in the context of an unknown thread.
// As a result, it must be thread-safe relative to other operations on
// the alarm list.
static void timer_callback(void *ptr) {
  alarm_t *alarm = (alarm_t *)ptr;
  assert(alarm != NULL);

  pthread_mutex_lock(&monitor);

  bool alarm_valid = list_remove(alarms, alarm);
  alarm_callback_t callback = alarm->callback;
  void *data = alarm->data;

  alarm->deadline = 0;
  alarm->callback = NULL;
  alarm->data = NULL;

  reschedule();

  // The alarm was cancelled before we got to it. Release the monitor
  // lock and exit right away since there's nothing left to do.
  if (!alarm_valid) {
    pthread_mutex_unlock(&monitor);
    return;
  }

  // Downgrade lock.
  pthread_mutex_lock(&alarm->callback_lock);
  pthread_mutex_unlock(&monitor);

  callback(data);

  pthread_mutex_unlock(&alarm->callback_lock);
}
开发者ID:AOSP-JF,项目名称:platform_external_bluetooth_bluedroid,代码行数:34,代码来源:alarm.c

示例10: fd_event

static void
fd_event (int error, void *context)
{
  struct serial *scb = context;
  if (error != 0)
    {
      scb->bufcnt = SERIAL_ERROR;
    }
  else if (scb->bufcnt == 0)
    {
      /* Prime the input FIFO.  The readchar() function is used to
         pull characters out of the buffer.  See also
         generic_readchar(). */
      int nr;
      nr = scb->ops->read_prim (scb, BUFSIZ);
      if (nr == 0)
	{
	  scb->bufcnt = SERIAL_EOF;
	}
      else if (nr > 0)
	{
	  scb->bufcnt = nr;
	  scb->bufp = scb->buf;
	}
      else
	{
	  scb->bufcnt = SERIAL_ERROR;
	}
    }
  scb->async_handler (scb, scb->async_context);
  reschedule (scb);
}
开发者ID:peterdocter,项目名称:toolchain-gdb,代码行数:32,代码来源:ser-base.c

示例11: assert

void DefaultFileSource::Impl::startRealRequest(DefaultFileRequest& request) {
    assert(!request.realRequest);

    // Cancel the timer if we have one.
    if (request.timerRequest) {
        request.timerRequest->stop();
    }

    auto callback = [this, &request](std::shared_ptr<const Response> response) {
        request.realRequest = nullptr;

        if (cache) {
            // Store response in database. Make sure we only refresh the expires column if the data
            // didn't change.
            FileCache::Hint hint = FileCache::Hint::Full;
            if (request.getResponse() && response->data == request.getResponse()->data) {
                hint = FileCache::Hint::Refresh;
            }
            cache->put(request.resource, response, hint);
        }

        request.setResponse(response);
        request.notify();
        reschedule(request);
    };

    if (algo::starts_with(request.resource.url, "asset://")) {
        request.realRequest =
            assetContext->createRequest(request.resource, callback, loop, assetRoot);
    } else {
        request.realRequest =
            httpContext->createRequest(request.resource, callback, loop, request.getResponse());
    }
}
开发者ID:roudunyy,项目名称:mapbox-gl-native,代码行数:34,代码来源:default_file_source.cpp

示例12: timer_wait

int timer_wait(unsigned int ticks)
{
	uint64_t eticks = per_core(timer_ticks) + ticks;

	task_t* curr_task = per_core(current_task);

	if (curr_task->status == TASK_IDLE)
	{
		/*
		 * This will continuously loop until the given time has
		 * been reached
		 */
		while (per_core(timer_ticks) < eticks) {
			check_workqueues();

			// recheck break condition
			if (per_core(timer_ticks) >= eticks)
				break;

			PAUSE;
		}
	} else if (per_core(timer_ticks) < eticks) {
		check_workqueues();

		if (per_core(timer_ticks) < eticks) {
			set_timer(eticks);
			reschedule();
		}
	}

	return 0;
}
开发者ID:RWTH-OS,项目名称:HermitCore,代码行数:32,代码来源:timer.c

示例13: dumpme

void
dumpme(int flag)
{
	int		f;
	double		x;
	struct event	*e;
	int		i;

	f = flag;
	Ship.quadx = ranf(NQUADS);
	Ship.quady = ranf(NQUADS);
	Ship.sectx = ranf(NSECTS);
	Ship.secty = ranf(NSECTS);
	x = 1.5 * franf();
	Move.time += x;
	if (f) {
		printf("%s falls into a black hole.\n", Ship.shipname);
	} else {
		printf("Computer applies full reverse power to avoid hitting "
		       "the\n");
		printf("   negative energy barrier.  A space warp was "
		       "entered.\n");
	}
	/* bump repair dates forward */
	for (i = 0; i < MAXEVENTS; i++) {
		e = &Event[i];
		if (e->evcode != E_FIXDV)
			continue;
		reschedule(e, (e->date - Now.date) + x);
	}
	events(1);
	printf("You are now in quadrant %d,%d.  It is stardate %.2f\n",
		Ship.quadx, Ship.quady, Now.date);
	Move.time = 0;
}
开发者ID:ajinkya93,项目名称:netbsd-src,代码行数:35,代码来源:dumpme.c

示例14: wake_thread

void wake_thread(unsigned int id)
{
    if(threads[id-1] != NULL)
        threads[id-1]->state = THREAD_READY;
    reschedule();
    return;
}
开发者ID:kylelutz,项目名称:link-os,代码行数:7,代码来源:thread.c

示例15: __attribute__

void __attribute__((noreturn)) kernel_main(unsigned int _memory_size)
{
    struct vm_translation_map *init_map;
    struct process *init_proc;

    vm_page_init(_memory_size);
    init_map = vm_translation_map_init();
    boot_init_heap((char*) KERNEL_HEAP_BASE + PAGE_STRUCTURES_SIZE(_memory_size));
    vm_address_space_init(init_map);
    bootstrap_vm_cache();
    bool_init_kernel_process();
    boot_init_thread();

    // Start other threads
    REGISTERS[REG_THREAD_RESUME] = 0xffffffff;

    spawn_kernel_thread("Grim Reaper", grim_reaper, 0);

    init_proc = exec_program("program.elf");

    // Idle task
    for (;;)
    {
        if (list_is_empty(&init_proc->thread_list))
        {
            kprintf("init process has exited, shutting down\n");
            REGISTERS[REG_THREAD_HALT] = 0xffffffff;
        }

        reschedule();
    }
}
开发者ID:award0707,项目名称:NyuziProcessor,代码行数:32,代码来源:main.c


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