Ejemplo n.º 1
0
Archivo: diexec.c Proyecto: bji/libmame
void device_execute_interface::on_vblank_start(screen_device &screen)
{
	// start the interrupt counter
	if (!suspended(SUSPEND_REASON_DISABLE))
		m_iloops = 0;
	else
		m_iloops = -1;

	// the hack style VBLANK decleration always uses the first screen
	bool interested = false;
	if (m_execute_config.m_vblank_interrupts_per_frame > 1)
		interested = true;

	// for new style declaration, we need to compare the tags
	else if (m_execute_config.m_vblank_interrupt_screen != NULL)
		interested = (strcmp(screen.tag(), m_execute_config.m_vblank_interrupt_screen) == 0);

	// if interested, call the interrupt handler
	if (interested)
	{
		if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
			(*m_execute_config.m_vblank_interrupt)(&m_device);

		// if we have more than one interrupt per frame, start the timer now to trigger the rest of them
		if (m_execute_config.m_vblank_interrupts_per_frame > 1 && !suspended(SUSPEND_REASON_DISABLE))
		{
			m_partial_frame_period = device().machine->primary_screen->frame_period() / m_execute_config.m_vblank_interrupts_per_frame;
			m_partial_frame_timer->adjust(m_partial_frame_period);
		}
	}
}
Ejemplo n.º 2
0
void device_execute_interface::interface_clock_changed()
{
	// a clock of zero disables the device
	if (device().clock() == 0)
	{
		suspend(SUSPEND_REASON_CLOCK, true);
		return;
	}

	// if we were suspended because we had no clock, enable us now
	if (suspended(SUSPEND_REASON_CLOCK))
		resume(SUSPEND_REASON_CLOCK);

	// recompute cps and spc
	m_cycles_per_second = clocks_to_cycles(device().clock());
	m_attoseconds_per_cycle = HZ_TO_ATTOSECONDS(m_cycles_per_second);

	// update the device's divisor
	INT64 attos = m_attoseconds_per_cycle;
	m_divshift = 0;
	while (attos >= (1UL << 31))
	{
		m_divshift++;
		attos >>= 1;
	}
	m_divisor = attos;

	// re-compute the perfect interleave factor
	m_scheduler->compute_perfect_interleave();
}
void XMLHttpRequestProgressEventThrottle::dispatchEvent(PassRefPtr<Event> event)
{
    ASSERT(!suspended());
    // We should not have any pending events from a previous resume.
    ASSERT(!m_pausedEvent);

    m_target->dispatchEvent(event);
}
void XMLHttpRequestProgressEventThrottle::dispatchPausedEvent()
{
    ASSERT(!suspended());
    if (!m_pausedEvent)
        return;

    m_target->dispatchEvent(m_pausedEvent);
    m_pausedEvent = 0;
}
Ejemplo n.º 5
0
void device_execute_interface::trigger_periodic_interrupt()
{
	// bail if there is no routine
	if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE | SUSPEND_REASON_CLOCK))
	{
		if (!m_timed_interrupt.isnull())
			m_timed_interrupt(device());
	}
}
Ejemplo n.º 6
0
bool SSTask::suspend()
{
	if(isRunning()){
		m_isWaiting = true;
		emit suspended();
		return true;
	}
	return false;
}
Ejemplo n.º 7
0
void device_execute_interface::trigger_periodic_interrupt()
{
	// bail if there is no routine
	if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
	{
		if (m_timed_interrupt_legacy != NULL)
			(*m_timed_interrupt_legacy)(&device());
		else if (!m_timed_interrupt.isnull())
			m_timed_interrupt(device());
	}
}
Ejemplo n.º 8
0
void Timer::
suspend()
{
    assert(m_state == TimerState::Running);
    assert(m_timer.isActive());

    m_timer.stop();
    changeState(TimerState::Suspended);

    Q_EMIT suspended();
}
Ejemplo n.º 9
0
int main() {
    try {
        squall::VMStd vm;
        vm.dofile("coroutine.nut");

        vm.co_call("bar", 1, 2, 3, 4);

        {
            auto co = vm.co_call("zot");
            while (co.suspended()) {
                co.resume();
            }
            std::cerr << "**** zot result: " << co.result<int>() << std::endl;
        }

        {
            auto co = vm.co_call("baz");
            while (co.suspended()) {
                int n = co.yielded<int>();
                std::cerr << "**** baz yielded: " << n << std::endl;
                co.resume();
            }
            std::cerr << "**** baz result: " << co.result<int>() << std::endl;
        }

        {
            auto co = vm.co_call("foo");
            while (co.suspended()) {
                int n = co.yielded<int>();
                std::cerr << "**** foo yielded: " << n << std::endl;
                co.resume(n*2);
            }
            std::cerr << "**** foo result: " << co.result<int>() << std::endl;
        }
    }
    catch(squall::squirrel_error& e) {
        std::cerr << e.what() << std::endl;
    }

    return 0;
}
Ejemplo n.º 10
0
void device_execute_interface::on_vblank(screen_device &screen, bool vblank_state)
{
	// ignore VBLANK end
	if (!vblank_state)
		return;

	// generate the interrupt callback
	if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE | SUSPEND_REASON_CLOCK))
	{
		if (!m_vblank_interrupt.isnull())
			m_vblank_interrupt(device());
	}
}
Ejemplo n.º 11
0
void device_execute_interface::on_vblank(screen_device &screen, bool vblank_state)
{
	// ignore VBLANK end
	if (!vblank_state)
		return;

	// start the interrupt counter
	if (!suspended(SUSPEND_REASON_DISABLE))
		m_iloops = 0;
	else
		m_iloops = -1;

	// generate the interrupt callback
	if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
		(*m_vblank_interrupt)(&m_device);

	// if we have more than one interrupt per frame, start the timer now to trigger the rest of them
	if (m_vblank_interrupts_per_frame > 1 && !suspended(SUSPEND_REASON_DISABLE))
	{
		m_partial_frame_period = device().machine().primary_screen->frame_period() / m_vblank_interrupts_per_frame;
		m_partial_frame_timer->adjust(m_partial_frame_period);
	}
}
Ejemplo n.º 12
0
//----------------------------------------------------------------------------
ctkExampleDicomHost::ctkExampleDicomHost(ctkHostedAppPlaceholderWidget* placeholderWidget, int hostPort, int appPort) :
    ctkDicomAbstractHost(hostPort, appPort),
    PlaceholderWidget(placeholderWidget),
    exitingApplication(false)
{
  connect(this,SIGNAL(appReady()),SLOT(onAppReady()));
  connect(this,SIGNAL(startProgress()),this,SLOT(onStartProgress()));
  connect(this,SIGNAL(releaseAvailableResources()),this,SLOT(onReleaseAvailableResources()));
  connect(this,SIGNAL(resumed()),this,SLOT(onResumed()));
  connect(this,SIGNAL(completed()),this,SLOT(onCompleted()));
  connect(this,SIGNAL(suspended()),this,SLOT(onSuspended()));
  connect(this,SIGNAL(canceled()),this,SLOT(onCanceled()));
  connect(this,SIGNAL(exited()),this,SLOT(onExited()));
}
Ejemplo n.º 13
0
boolean Task::run_task()
{
  D_JOS("Running task");
  boolean result = false;
  if (!suspended()) {
    D_JOS("Task wasn't suspended");
    result = run();
    ++_run_state;
  }
  else {
    D_JOS("Task was suspended");
  }
  return result;
}
Ejemplo n.º 14
0
void CompositeAnimation::cleanupFinishedAnimations(RenderObject* renderer)
{
    if (suspended())
        return;
    
    // Make a list of transitions to be deleted
    Vector<int> finishedTransitions;
    CSSPropertyTransitionsMap::const_iterator end = m_transitions.end();

    for (CSSPropertyTransitionsMap::const_iterator it = m_transitions.begin(); it != end; ++it) {
        ImplicitAnimation* anim = it->second;
        if (!anim)
            continue;
        if (anim->postActive() && !anim->waitingForEndEvent())
            finishedTransitions.append(anim->animatingProperty());
    }
    
    // Delete them
    for (Vector<int>::iterator it = finishedTransitions.begin(); it != finishedTransitions.end(); ++it) {
        ImplicitAnimation* anim = m_transitions.get(*it);
        if (anim) {
            anim->reset(renderer);
            delete anim;
        }
        m_transitions.remove(*it);
    }

    // Make a list of animations to be deleted
    Vector<AtomicStringImpl*> finishedAnimations;
    AnimationNameMap::const_iterator kfend = m_keyframeAnimations.end();

    for (AnimationNameMap::const_iterator it = m_keyframeAnimations.begin(); it != kfend; ++it) {
        KeyframeAnimation* anim = it->second;
        if (!anim)
            continue;
        if (anim->postActive() && !anim->waitingForEndEvent())
            finishedAnimations.append(anim->name().impl());
    }
    
    // delete them
    for (Vector<AtomicStringImpl*>::iterator it = finishedAnimations.begin(); it != finishedAnimations.end(); ++it) {
        KeyframeAnimation* kfanim = m_keyframeAnimations.get(*it);
        if (kfanim) {
            kfanim->reset(renderer);
            delete kfanim;
        }
        m_keyframeAnimations.remove(*it);
    }
}
void XMLHttpRequestProgressEventThrottle::fired()
{
    ASSERT(isActive());
    ASSERT(!suspended());
    ASSERT(!m_pausedEvent);
    if (!hasEventToDispatch()) {
        // No progress event was queued since the previous dispatch, we can safely stop the timer.
        stop();
        return;
    }

    m_target->dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, m_lengthComputable, m_loaded, m_total));
    m_total = 0;
    m_loaded = 0;
}
Ejemplo n.º 16
0
bool KJob::suspend()
{
    Q_D(KJob);
    if ( !d->suspended )
    {
        if ( doSuspend() )
        {
            d->suspended = true;
            emit suspended(this);

            return true;
        }
    }

    return false;
}
Ejemplo n.º 17
0
Archivo: diexec.c Proyecto: bji/libmame
void device_execute_interface::trigger_partial_frame_interrupt()
{
	// when we hit 0, reset to the total count
	if (m_iloops == 0)
		m_iloops = m_execute_config.m_vblank_interrupts_per_frame;

	// count one more "iloop"
	m_iloops--;

	// call the interrupt handler if we're not suspended
	if (!suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
		(*m_execute_config.m_vblank_interrupt)(&m_device);

	// set up to retrigger if there's more interrupts to generate
	if (m_iloops > 1)
		m_partial_frame_timer->adjust(m_partial_frame_period);
}
Ejemplo n.º 18
0
void request_from_daemon(proc_data* data){

  //  printf("Request From Daemon ...(%d)\n",data->REQUEST);

  switch(data->REQUEST){
  case MIGRATE:
    //    printf("MIGRATE REQUEST (%d TO THE %d)!!!!!!!!!!!!!!!\n",mocu_pos,data->pos);
    mocu_migrate(data->pos);
    break;
  case SUSPEND:
    suspended();
    break;
  case CANNOTENTER:
    cannot_enter();
    break;
  case CONNECT:
    //TODO Nothing
    break;
  }
}
void XMLHttpRequestProgressEventThrottle::dispatchProgressEvent(bool lengthComputable, unsigned loaded, unsigned total)
{
    ASSERT(!suspended());
    if (!isActive()) {
        // The timer is not active so the least frequent event for now is every byte.
        // Just go ahead and dispatch the event.

        // We should not have any pending loaded & total information from a previous run.
        ASSERT(!m_loaded);
        ASSERT(!m_total);

        dispatchEvent(XMLHttpRequestProgressEvent::create(eventNames().progressEvent, lengthComputable, loaded, total));
        startRepeating(minimumProgressEventDispatchingIntervalInSeconds);
        return;
    }

    // The timer is already active so minimumProgressEventDispatchingIntervalInSeconds is the least frequent event.
    m_lengthComputable = lengthComputable;
    m_loaded = loaded;
    m_total = total;
}
Ejemplo n.º 20
0
void failed_to_get(int size){

  int result;
  proc_data* data;

  data = (proc_data*)malloc(sizeof(proc_data));
  data->REQUEST = FAILEDTOGET;
  data->pid = getpid();
  data->pos = mocu_pos;
  //  data->canmig = canmig;
  data->flag = canmig;
  data->mem = mocu_get_amount_of_memory_used()+size;

  result = send(sockfd,data,sizeof(proc_data),0);

  if(result == -1){
    printf("Failed to send msg\n");
    exit(-1);
  }

  suspended();
}
Ejemplo n.º 21
0
Archivo: diexec.c Proyecto: bji/libmame
void device_execute_interface::trigger_periodic_interrupt()
{
	// bail if there is no routine
	if (m_execute_config.m_timed_interrupt != NULL && !suspended(SUSPEND_REASON_HALT | SUSPEND_REASON_RESET | SUSPEND_REASON_DISABLE))
		(*m_execute_config.m_timed_interrupt)(&m_device);
}
Ejemplo n.º 22
0
int VariableCheck(Store store, Indexicals indexicals, Stamp *s, Cola Q)
     /*---------------------------------------------------------------
       DESCRIPCION: Implementacion del algoritmo resolutivo basico.
       PARAMETROS: Q: es una cola de variables
                   store : Es el store del Sistema de Restricciones.
         indexicals: Son los indexicals que representan las
         restricciones impuestas sobre el store.
         s: Marca de tiempo para la evaluacion de los indexicals
       USA:
       RETORNA: El estado de la operacion
       PRE:
       POS: La Ope = FAIL || Ope = SUCCESS.
       NOTAS:
       ---------------------------------------------------------------*/
{
  int tokeny, posIndexical, xkey, monot_f;
  FDVariable fdvariabley;
  Domain x_sigma, r_sigma, I;
  Lista IndexSusy;
  Indexical f;

  while(!vaciaCola(Q))
    {/* Mientra la cola no este vacia */
      tokeny = infoCola(Q);
      fdvariabley = getVariableStore(store, tokeny);
      elimCola(Q); /* Q = Q \ {y} */
      IndexSusy = suspended(store, tokeny); /* Indexicals que dependen de la variable y */

      for ( primLista(IndexSusy); !finLista(IndexSusy); sigLista(IndexSusy))
   {
     posIndexical = infoLista(IndexSusy);
     f = elementAtIndexicals(indexicals, posIndexical);
     if (getEntailed(f)) /* Si f esta marcada como deducido */
         {
      indexicals = removeElementAtIndexicals(indexicals, posIndexical);
      store = desrefVariableDepStore(store, posIndexical);
         }
     else
       {
         if(getStampFDVariable(fdvariabley) >= getStamp(f))
      {
        xkey = getX(f);
        x_sigma = Inicp1Domain(getDomainFDVariable(getVariableStore(store, xkey)));
        r_sigma = r_Sigma(store,f);
        I = Inicp1Domain(x_sigma);
        intersectionDomain(I, r_sigma);
        setStamp(f, *s);
        indexicals = setElementAtIndexicals(indexicals, f, posIndexical);
        monot_f = Monotonicity(getCodef(f),store);
        if (!isConsistentDomain(I))
          {/* <Vacio> */
            if (monot_f == MONOTONE|| monot_f == CONSTANT)
         {
           freeDomain(x_sigma);
           freeDomain(r_sigma);
           freeDomain(I);
           freeIndexical(f);
           destruirLista(IndexSusy);
           return FAIL;
         }
          }
        else if (equalsDomain(I, x_sigma)) /* x_sigma */
          {
            if (monot_f == ANTIMONOTONE)
         {
           setEntailed(f,TRUE);
           indexicals = removeElementAtIndexicals(indexicals, posIndexical);
           store = desrefVariableDepStore(store, posIndexical);  
         }
           
          }
        else
          {/* otherwise */
            if (monot_f == MONOTONE || monot_f == CONSTANT)
         {
           (*s)++;
           store = updateVarStampStore(store, xkey,*s);
           if (!updateVarDomStore(store, xkey,I))
             {
               freeDomain(x_sigma);
               freeDomain(r_sigma);
               freeDomain(I);
               freeIndexical(f);
               destruirLista(IndexSusy);
               return FAIL;
             }
           if (!existeElementoCola(Q,xkey))
             {
               adicCola(Q,xkey);
             }
           if (monot_f == CONSTANT)
             {
               setEntailed(f, TRUE);
               indexicals = removeElementAtIndexicals(indexicals, posIndexical);
               store = desrefVariableDepStore(store, posIndexical); 
             }
         }
          }
        freeDomain(x_sigma);
        freeDomain(r_sigma);
        freeDomain(I);
      }
       }
     freeIndexical(f);
   }
      destruirLista(IndexSusy);
    }
  return SUCCESS;
}