コード例 #1
0
/**
 * Reduce the root's degree by linking it's three rightmost passive nodes.
 *
 * @param queue Queue in which to operate
 */
static int reduce_root_degree( strict_fibonacci_heap *queue )
{
    if( queue->root == NULL || queue->root->left_child == NULL )
        return 0;

    strict_fibonacci_node *x = queue->root->left_child->left;
    if( x == queue->root->left_child || is_active( queue, x ) )
        return 0;

    strict_fibonacci_node *y = x->left;
    if( y == queue->root->left_child || is_active( queue, y ) )
        return 0;

    strict_fibonacci_node *z = y->left;
    if( z == queue->root->left_child || is_active( queue, z ) )
        return 0;

    strict_fibonacci_node *grand, *parent, *child;
    choose_order_triple( x, y, z, &grand, &parent, &child );

    convert_passive_to_active( queue, parent );
    convert_passive_to_active( queue, grand );
    increase_rank( queue, grand );
    if( !is_active( queue, queue->root ) )
        convert_active_to_root( queue, grand );

    link( queue, parent, child );
    link( queue, grand, parent );

    return 1;
}
コード例 #2
0
ファイル: builtin_echo.c プロジェクト: 42sh-niccheva/42sh
int				builtin_echo(int argc, const char **argv, char **env)
{
	t_command	*command;
	int			i;

	(void)argc;
	(void)env;
	command = builtin_echo_init();
	if (!parse_command(argv, command))
		return (0);
	if (is_active(command, "help"))
		details_of_command(command);
	else
	{
		i = skip_options(argv);
		while (argv[i])
		{
			if (display_arg(command, argv[i]))
				return (0);
			if (argv[++i])
				ft_putchar(' ');
		}
		if (!is_active(command, "n"))
			ft_putchar('\n');
	}
	return (0);
}
コード例 #3
0
ファイル: menus.cpp プロジェクト: wixur/teeworlds-ng
bool MENUS::on_input(INPUT_EVENT e)
{
	last_input = time_get();
	
	// special handle esc and enter for popup purposes
	if(e.flags&INPFLAG_PRESS)
	{
		if(e.key == KEY_ESCAPE)
		{
			escape_pressed = true;
			set_active(!is_active());
			return true;
		}
	}
		
	if(is_active())
	{
		// special for popups
		if(e.flags&INPFLAG_PRESS && e.key == KEY_RETURN)
			enter_pressed = true;
		
		if(num_inputevents < MAX_INPUTEVENTS)
			inputevents[num_inputevents++] = e;
		return true;
	}
	return false;
}
コード例 #4
0
/**
 * Convert an active node to a passive one.  Release all fix nodes, active and
 * rank records.
 *
 * @param queue Queue in which to operate
 * @param node  Node to convert
 */
static void convert_to_passive( strict_fibonacci_heap *queue,
                                strict_fibonacci_node *node )
{
    if( node->fix != NULL )
    {
        remove_fix_node( queue, node->fix, ( node->type == STRICT_TYPE_ROOT ) ?
                         STRICT_FIX_ROOT : STRICT_FIX_LOSS );
        pq_free_node( queue->map, STRICT_NODE_FIX, node->fix );
        node->fix = NULL;
    }

    release_rank_record( queue, node );
    release_active_record( queue, node );
    node->type = STRICT_TYPE_PASSIVE;

    if( node->parent != NULL )
        link( queue, node->parent, node );

    if( node->left_child == NULL )
        return;

    strict_fibonacci_node *current = node->left_child;
    if( is_active( queue, current ) && current->type == STRICT_TYPE_ACTIVE )
        convert_active_to_root( queue, current );
    current = current->right;
    while( current != node->left_child )
    {
        if( is_active( queue, current ) && current->type == STRICT_TYPE_ACTIVE )
            convert_active_to_root( queue, current );
        current = current->right;
    }
}
コード例 #5
0
key_type pq_delete_min( strict_fibonacci_heap *queue )
{
    if( pq_empty( queue ) )
        return 0;

    key_type key = queue->root->key;
    strict_fibonacci_node *current, *new_root, *old_root;
    int i, j;

    old_root = queue->root;

    if( old_root->left_child == NULL )
    {
        old_root = queue->root;
        if( is_active( queue, old_root ) )
            convert_to_passive( queue, old_root );
        queue->root = NULL;
    }
    else
    {
        new_root = select_new_root( queue );
        remove_from_siblings( queue, new_root );
        dequeue_node( queue, new_root );
        queue->root = new_root;

        if( is_active( queue, new_root ) )
            convert_to_passive( queue, new_root );
        if( is_active( queue, old_root ) )
            convert_to_passive( queue, old_root );

        while( old_root->left_child != NULL )
            link( queue, new_root, old_root->left_child );

        for( i = 0; i < 2; i++ )
        {
            current = consume_node( queue );
            if( current != NULL )
            {
                for( j = 0; j < 2; j++ )
                {
                    if( current->left_child != NULL &&
                            !is_active( queue, current->left_child->left ) )
                        link( queue, new_root, current->left_child->left );
                    else
                        break;
                }
            }
        }
    }

    pq_free_node( queue->map, STRICT_NODE_FIB, old_root );

    post_delete_min_reduction( queue );
    garbage_collection( queue );

    queue->size--;

    return key;
}
コード例 #6
0
ファイル: Pane.cpp プロジェクト: CSRedRat/ridual
void Pane::active_pane_changed() {
  QFont font = ui->address->font();
  font.setBold(is_active());
  ui->address->setFont(font);
  if (is_active()) {
    ui->list->setFocus();
  }
  update_model_current_index();
}
コード例 #7
0
ファイル: animation_player.cpp プロジェクト: arcanis/godot
bool AnimationPlayer::_get(const StringName &p_name, Variant &r_ret) const {

	String name = p_name;

	if (name == "playback/speed") { //bw compatibility

		r_ret = speed_scale;
	} else if (name == "playback/active") {

		r_ret = is_active();
	} else if (name == "playback/play") {

		if (is_active() && is_playing())
			r_ret = playback.assigned;
		else
			r_ret = "[stop]";

	} else if (name.begins_with("anims/")) {

		String which = name.get_slicec('/', 1);

		r_ret = get_animation(which).get_ref_ptr();
	} else if (name.begins_with("next/")) {

		String which = name.get_slicec('/', 1);

		r_ret = animation_get_next(which);

	} else if (name == "blend_times") {

		Vector<BlendKey> keys;
		for (Map<BlendKey, float>::Element *E = blend_times.front(); E; E = E->next()) {

			keys.ordered_insert(E->key());
		}

		Array array;
		for (int i = 0; i < keys.size(); i++) {

			array.push_back(keys[i].from);
			array.push_back(keys[i].to);
			array.push_back(blend_times[keys[i]]);
		}

		r_ret = array;
	} else if (name == "autoplay") {
		r_ret = autoplay;

	} else
		return false;

	return true;
}
コード例 #8
0
bool AnimationPlayer::_get(const StringName& p_name,Variant &r_ret) const {

	String name=p_name;

	if (name=="playback/speed") { //bw compatibility
	
		r_ret=speed_scale;
	} else if (name=="playback/active") {

		r_ret=is_active();
	} else if (name=="playback/play") {

		if (is_active() && is_playing())
			r_ret=playback.assigned;
		else
			r_ret="[stop]";

	} else if (name.begins_with("anims/")) {
	
		String which=name.get_slicec('/',1);
		
		r_ret= get_animation(which).get_ref_ptr();
	} else if (name.begins_with("next/")) {

		String which=name.get_slicec('/',1);

		r_ret= animation_get_next(which);


	} else if (name=="blend_times") {
	
		Array array;

		array.resize(blend_times.size()*3);
		int idx=0;
		for(Map<BlendKey, float >::Element *E=blend_times.front();E;E=E->next()) {

			array.set(idx*3+0,E->key().from);
			array.set(idx*3+1,E->key().to);
			array.set(idx*3+2,E->get());
			idx++;
		}
		r_ret=array;
	} else if (name=="autoplay") {
		r_ret=autoplay;


	} else
		return false;

	return true;
}
コード例 #9
0
bool BlobTracker::addActivity(int x, int y, unsigned long int ts,
                              double Tact, double Tevent)
{
    activity_ += 1;//p;

    double delta_sig_x2 = (x-cen_x_)*(x-cen_x_);
    double delta_sig_y2 = (y-cen_y_)*(y-cen_y_);
    double delta_sig_xy;

    if(fixed_shape_){
        delta_sig_x2 = (delta_sig_x2 + delta_sig_y2)/2;
        delta_sig_y2 = delta_sig_x2;
        delta_sig_xy = 0;
    }
    else{
        delta_sig_xy = (x-cen_x_)*(y-cen_y_);
    }

    sig_x2_ = (1-alpha_shape_)*sig_x2_ + alpha_shape_*delta_sig_x2;
    sig_y2_ = (1-alpha_shape_)*sig_y2_ + alpha_shape_*delta_sig_y2;
    sig_xy_ = (1-alpha_shape_)*sig_xy_ + alpha_shape_*delta_sig_xy;

    double old_x = cen_x_;
    double old_y = cen_y_;

    cen_x_ = (1-alpha_pos_)*cen_x_ + alpha_pos_*x;
    cen_y_ = (1-alpha_pos_)*cen_y_ + alpha_pos_*y;

    double alpha = 0.2;
    double dt = ts-ts_last_update_;

    if(dt>0){
        vx_ = (1-alpha)*vx_ + alpha*(cen_x_-old_x)/dt;
        vy_ = (1-alpha)*vy_ + alpha*(cen_y_-old_y)/dt;
    }
    ts_last_update_ = ts;

    //return true if just turned on
    if(!is_active() && activity_ > Tact) {
        state_ = Active;
        return true;
    }

    //return true if moved enough
    double distance = sqrt(std::pow(vLastX - cen_x_, 2.0) +
                           std::pow(vLastY - cen_y_, 2.0));
    if(is_active() && distance > Tevent) {
        return true;
    }

    return false;
}
コード例 #10
0
ファイル: DICe_Subset.cpp プロジェクト: cooperrc/dice
void
Subset::turn_on_previously_obstructed_pixels(){
  // this assumes that the is_deactivated_this_step_ flags have already been set correctly prior
  // to calling this method.
  for(int_t px=0;px<num_pixels_;++px){
    // it's not obstructed this step, but was inactive to begin with
    if(!is_deactivated_this_step(px) && !is_active(px)){
      // take the pixel value from the deformed subset
      ref_intensities(px) = def_intensities(px);
      // set the active bit to true
      is_active(px) = true;
    }
  }
}
コード例 #11
0
ファイル: Pane.cpp プロジェクト: Amartel1986/ridual
void Pane::active_pane_changed() {
  QFont font = ui->address->font();
  font.setBold(is_active());
  ui->address->setFont(font);
  if (is_active()) {
    ui->list->setFocus();
  }

  if (is_active()) {
    file_list_model.set_current_index(ui->list->selectionModel()->currentIndex());
  } else {
    file_list_model.set_current_index(file_list_model.index(-1 , -1));
  }
}
コード例 #12
0
ファイル: badguy.cpp プロジェクト: SuperTux/supertux
HitResponse
BadGuy::collision(GameObject& other, const CollisionHit& hit)
{
  if (!is_active()) return ABORT_MOVE;

  auto badguy = dynamic_cast<BadGuy*> (&other);
  if (badguy && badguy->is_active() && badguy->m_col.get_group() == COLGROUP_MOVING) {

    /* Badguys don't let badguys squish other badguys. It's bad. */
#if 0
    // hit from above?
    if (badguy->get_bbox().get_bottom() < (bbox.get_top() + 16)) {
      if (collision_squished(*badguy)) {
        return ABORT_MOVE;
      }
    }
#endif

    return collision_badguy(*badguy, hit);
  }

  auto player = dynamic_cast<Player*> (&other);
  if (player) {

    // hit from above?
    if (player->get_bbox().get_bottom() < (m_col.m_bbox.get_top() + 16)) {
      if (player->is_stone()) {
        kill_fall();
        return FORCE_MOVE;
      }
      if (collision_squished(*player)) {
        return FORCE_MOVE;
      }
    }

    if (player->is_stone()) {
      collision_solid(hit);
      return FORCE_MOVE;
    }

    return collision_player(*player, hit);
  }

  auto bullet = dynamic_cast<Bullet*> (&other);
  if (bullet)
    return collision_bullet(*bullet, hit);

  return FORCE_MOVE;
}
コード例 #13
0
t_count t_spectra::get_suspicious_components_count (t_candidate & suspicious,
                                                    const t_spectra_filter * filter) const {
    t_spectra_filter tmp;


    if (filter)
        tmp = *filter;

    tmp.components.filter_all(suspicious);

    t_spectra_iterator it(get_component_count(),
                          get_transaction_count(),
                          &tmp);

    while (it.transaction.next()) {
        if (!is_error(it.transaction.get())) // TODO: Improve performance by maintaining a filter of all failing transactions

            continue;

        while (it.component.next()) {
            if (is_active(it.component.get(), it.transaction.get())) {
                tmp.components.filter(it.component.get());
                suspicious.insert(it.component.get());
            }
        }
    }

    return suspicious.size();
}
コード例 #14
0
ファイル: AR_WPNav.cpp プロジェクト: Rusty105/ardupilot
// update navigation
void AR_WPNav::update(float dt)
{
    // exit immediately if no current location, origin or destination
    Location current_loc;
    float speed;
    if (!hal.util->get_soft_armed() || !_orig_and_dest_valid || !AP::ahrs().get_position(current_loc) || !_atc.get_forward_speed(speed)) {
        _desired_speed_limited = _atc.get_desired_speed_accel_limited(0.0f, dt);
        _desired_turn_rate_rads = 0.0f;
        return;
    }

    // if no recent calls initialise desired_speed_limited to current speed
    if (!is_active()) {
        _desired_speed_limited = speed;
    }
    _last_update_ms = AP_HAL::millis();

    update_distance_and_bearing_to_destination();

    // check if vehicle has reached the destination
    const bool near_wp = _distance_to_destination <= _radius;
    const bool past_wp = current_loc.past_interval_finish_line(_origin, _destination);
    if (!_reached_destination && (near_wp || past_wp)) {
       _reached_destination = true;
    }

    // calculate the required turn of the wheels
    update_steering(current_loc, speed);

    // calculate desired speed
    update_desired_speed(dt);
}
コード例 #15
0
ファイル: aprofiler.cpp プロジェクト: AllenWeb/openjdk-1
void AllocationProfiler::iterate_since_last_gc() {
  if (is_active()) {
    AllocProfClosure blk;
    GenCollectedHeap* heap = GenCollectedHeap::heap();
    heap->object_iterate_since_last_GC(&blk);
  }
}
コード例 #16
0
ファイル: tabbar.cpp プロジェクト: snori/ntk
void
TabBar::Tab::draw(DC& dc)
{
	const RGBColor ACTIVE_COLOR = ntk::app_color();// + 30;
	Rect rect = frame();
	rect.top += 1;

	dc.push_state();

	if(is_active())
	{
		dc.set_brush(ACTIVE_COLOR);
		dc.fill_rect(rect);

		dc.set_pen(ntk::outline_color());
		dc.stroke_line(rect.left_top(), rect.left_bottom());
		dc.stroke_line(rect.left_top(), rect.right_top());
		dc.stroke_line(rect.right_top(), rect.right_bottom());

		dc.set_text_color(ntk::font_color());
	}
	else
		dc.set_text_color(ntk::font_color() - 30);

	ntk::draw_string_center(dc, rect, name());

	dc.pop_state();
}
コード例 #17
0
ファイル: timer.cpp プロジェクト: oudream/ucommon
Timer& Timer::operator-=(time_t abs)
{
    if(!is_active())
        set();
    timer.tv_sec -= _difftime(abs);
    return *this;
}
コード例 #18
0
bool CControlCriticalWound::check_start_conditions()
{
	if (is_active())						return false;	
	if (m_man->is_captured_pure())			return false;

	return true;
}
コード例 #19
0
state_t &
state_t::time_limit(
	duration_t timeout,
	const state_t & state_to_switch )
{
	if( duration_t::zero() == timeout )
		SO_5_THROW_EXCEPTION( rc_invalid_time_limit_for_state,
				"zero can't be used as time limit for state '" +
				query_name() );

	// Old time limit must be dropped if it exists.
	drop_time_limit();
	m_time_limit.reset( new time_limit_t{ timeout, state_to_switch } );

	// If this state is active then new time limit must be activated.
	if( is_active() )
		so_5::details::do_with_rollback_on_exception(
			[&] {
				m_time_limit->set_up_limit_for_agent( *m_target_agent, *this );
			},
			[&] {
				// Time limit must be dropped because it is not activated
				// for the current state.
				drop_time_limit();
			} );

	return *this;
}
コード例 #20
0
ファイル: ipc_port.c プロジェクト: Bitesher/xnu
ipc_port_t
ipc_port_lookup_notify(
	ipc_space_t		space,
	mach_port_name_t	name)
{
	ipc_port_t port;
	ipc_entry_t entry;

	assert(is_active(space));

	entry = ipc_entry_lookup(space, name);
	if (entry == IE_NULL)
		return IP_NULL;
	if ((entry->ie_bits & MACH_PORT_TYPE_RECEIVE) == 0)
		return IP_NULL;

	port = (ipc_port_t) entry->ie_object;
	assert(port != IP_NULL);

	ip_lock(port);
	assert(ip_active(port));
	assert(port->ip_receiver_name == name);
	assert(port->ip_receiver == space);

	ip_reference(port);
	port->ip_sorights++;
	ip_unlock(port);

	return port;
}
コード例 #21
0
ファイル: PhysicObject.cpp プロジェクト: AntonioModer/xray-16
void CPhysicObject::UpdateCL()
{
	inherited::UpdateCL();

	//Если наш физический объект анимированный, то 
	//двигаем объект за анимацией
	if (m_pPhysicsShell->PPhysicsShellAnimator())
	{
		m_pPhysicsShell->AnimatorOnFrame();
	}
	
	if (!IsGameTypeSingle())
	{
		Interpolate();
	}

	m_anim_script_callback.update( *this );
	PHObjectPositionUpdate();

#ifdef	DEBUG
if(dbg_draw_doors)
{
	Fvector c,o;
	get_door_vectors( c, o );
}
#endif

	if( !is_active( bones_snd_player ) )
		return;
	bones_snd_player->update( Device.fTimeDelta, *this );

}
コード例 #22
0
ファイル: DICe_Subset.cpp プロジェクト: cooperrc/dice
void
Subset::write_tiff(const std::string & file_name,
  const bool use_def_intensities){
  // determine the extents of the subset and the offsets
  int_t max_x = 0;
  int_t max_y = 0;
  int_t min_x = x(0);
  int_t min_y = y(0);
  for(int_t i=0;i<num_pixels_;++i){
    if(x(i) > max_x) max_x = x(i);
    if(x(i) < min_x) min_x = x(i);
    if(y(i) > max_y) max_y = y(i);
    if(y(i) < min_y) min_y = y(i);
  }
  //create a square image that fits the extents of the subet
  const int_t w = max_x - min_x + 1;
  const int_t h = max_y - min_y + 1;
  intensity_t * intensities = new intensity_t[w*h];
  for(int_t i=0;i<w*h;++i)
    intensities[i] = 0.0;
  for(int_t i=0;i<num_pixels_;++i){
    if(!is_active(i)){
      intensities[(y(i)-min_y)*w+(x(i)-min_x)] = 100; // color the inactive areas gray
    }
    else{
      intensities[(y(i)-min_y)*w+(x(i)-min_x)] = use_def_intensities ?
          def_intensities(i) : ref_intensities(i);
    }
  }
  utils::write_image(file_name.c_str(),w,h,intensities,true);
  delete[] intensities;
}
コード例 #23
0
ファイル: badguy.cpp プロジェクト: SuperTux/supertux
void
BadGuy::collision_tile(uint32_t tile_attributes)
{
  // Don't kill badguys that have already been killed
  if (!is_active()) return;

  if (tile_attributes & Tile::WATER && !is_in_water())
  {
    m_in_water = true;
    SoundManager::current()->play("sounds/splash.ogg", get_pos());
  }
  if (!(tile_attributes & Tile::WATER) && is_in_water())
  {
    m_in_water = false;
  }

  if (tile_attributes & Tile::HURTS && is_hurtable()) {
    if (tile_attributes & Tile::FIRE) {
      if (is_flammable()) ignite();
    }
    else if (tile_attributes & Tile::ICE) {
      if (is_freezable()) freeze();
    }
    else {
      kill_fall();
    }
  }
}
コード例 #24
0
ファイル: mach_debug.c プロジェクト: JackieXie168/xnu
kern_return_t
mach_port_space_basic_info(
	ipc_space_t			space,
	ipc_info_space_basic_t		*infop)
{
	if (space == IS_NULL)
		return KERN_INVALID_TASK;


	is_read_lock(space);
	if (!is_active(space)) {
		is_read_unlock(space);
		return KERN_INVALID_TASK;
	}

	/* get the basic space info */
	infop->iisb_genno_mask = MACH_PORT_NGEN(MACH_PORT_DEAD);
	infop->iisb_table_size = space->is_table_size;
	infop->iisb_table_next = space->is_table_next->its_size;
	infop->iisb_table_inuse = space->is_table_size - space->is_table_free - 1;
	infop->iisb_reserved[0] = 0;
	infop->iisb_reserved[1] = 0;

	is_read_unlock(space);

	return KERN_SUCCESS;
}
コード例 #25
0
static int
xenoprof_handler(struct task_struct *task, void *buf, pfm_ovfl_arg_t *arg,
                 struct pt_regs *regs, unsigned long stamp)
{
    unsigned long ip = profile_pc(regs);
    int event = arg->pmd_eventid;
    struct vcpu *v = current;
    int mode = xenoprofile_get_mode(v, regs);

    // see pfm_do_interrupt_handler() in xen/arch/ia64/linux-xen/perfmon.c.
    // It always passes task as NULL. This is work around
    BUG_ON(task != NULL);

    arg->ovfl_ctrl.bits.reset_ovfl_pmds = 1;
    if (!allow_virq || !allow_ints)
        return 0;

    // Note that log event actually expect cpu_user_regs, cast back 
    // appropriately when doing the backtrace implementation in ia64
    xenoprof_log_event(v, regs, ip, mode, event);
    // send VIRQ_XENOPROF
    if (is_active(v->domain) && !xenoprof_is_xen_mode(v, regs) &&
        !is_idle_vcpu(v))
        send_guest_vcpu_virq(v, VIRQ_XENOPROF);

    return 0;
}
コード例 #26
0
void ConcurrentG1RefineThread::run() {
  initialize_in_thread();
  wait_for_universe_init();

  if (_worker_id >= cg1r()->worker_thread_num()) {
    run_young_rs_sampling();
    terminate();
  }

  _vtime_start = os::elapsedVTime();
  while (!_should_terminate) {
    DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();

    // Wait for work
    wait_for_completed_buffers();

    if (_should_terminate) {
      break;
    }

    _sts.join();

    do {
      int curr_buffer_num = (int)dcqs.completed_buffers_num();
      // If the number of the buffers falls down into the yellow zone,
      // that means that the transition period after the evacuation pause has ended.
      if (dcqs.completed_queue_padding() > 0 && curr_buffer_num <= cg1r()->yellow_zone()) {
        dcqs.set_completed_queue_padding(0);
      }

      if (_worker_id > 0 && curr_buffer_num <= _deactivation_threshold) {
        // If the number of the buffer has fallen below our threshold
        // we should deactivate. The predecessor will reactivate this
        // thread should the number of the buffers cross the threshold again.
        deactivate();
        break;
      }

      // Check if we need to activate the next thread.
      if (_next != NULL && !_next->is_active() && curr_buffer_num > _next->_threshold) {
        _next->activate();
      }
    } while (dcqs.apply_closure_to_completed_buffer(_worker_id + _worker_id_offset, cg1r()->green_zone()));

    // We can exit the loop above while being active if there was a yield request.
    if (is_active()) {
      deactivate();
    }

    _sts.leave();

    if (os::supports_vtime()) {
      _vtime_accum = (os::elapsedVTime() - _vtime_start);
    } else {
      _vtime_accum = 0.0;
    }
  }
  assert(_should_terminate, "just checking");
  terminate();
}
コード例 #27
0
ファイル: StreamAction.cpp プロジェクト: Codex-NG/solarus
/**
 * \brief Updates the direction of the movement to the target.
 *
 * This function should be called periodically.
 */
void StreamAction::recompute_movement() {

  if (!is_active()) {
    return;
  }

  // Compute the direction of the movement and its target point.
  const int direction8 = stream->get_direction();
  const Point& xy = Entity::direction_to_xy_move(direction8);
  const int dx = xy.x;
  const int dy = xy.y;
  delay = (uint32_t) (1000 / stream->get_speed());

  target = stream->get_xy();

  // Stop 16 pixels after the stream.
  if (dx != 0) {
    // Horizontal stream.
    target.x = stream->get_x() + (dx > 0 ? 16 : -16);
  }

  if (dy != 0) {
    // Vertical stream.
    target.y = stream->get_y() + (dy > 0 ? 16 : -16);
  }

  if (target != entity_moved->get_xy()) {
    // Adjust the speed to the diagonal movement.
    delay = (uint32_t) (delay * std::sqrt(2));
  }
}
コード例 #28
0
ファイル: signal.hpp プロジェクト: BackupTheBerlios/fieldbus
			virtual void disconnect()
			{
				if( !is_active() ) return;
				l_.erase(it_);
				active_ = false;
				--ref_;
			}
コード例 #29
0
void ConcurrentG1RefineThread::wait_for_completed_buffers() {
  DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set();
  MutexLockerEx x(_monitor, Mutex::_no_safepoint_check_flag);
  while (!_should_terminate && !is_active()) {
    _monitor->wait(Mutex::_no_safepoint_check_flag);
  }
}
コード例 #30
0
ファイル: msm_gem.c プロジェクト: 513855417/linux
void msm_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
{
	struct msm_gem_object *msm_obj = to_msm_bo(obj);
	struct reservation_object *robj = msm_obj->resv;
	struct reservation_object_list *fobj;
	struct fence *fence;
	uint64_t off = drm_vma_node_start(&obj->vma_node);

	WARN_ON(!mutex_is_locked(&obj->dev->struct_mutex));

	seq_printf(m, "%08x: %c %2d (%2d) %08llx %p %zu\n",
			msm_obj->flags, is_active(msm_obj) ? 'A' : 'I',
			obj->name, obj->refcount.refcount.counter,
			off, msm_obj->vaddr, obj->size);

	rcu_read_lock();
	fobj = rcu_dereference(robj->fence);
	if (fobj) {
		unsigned int i, shared_count = fobj->shared_count;

		for (i = 0; i < shared_count; i++) {
			fence = rcu_dereference(fobj->shared[i]);
			describe_fence(fence, "Shared", m);
		}
	}

	fence = rcu_dereference(robj->fence_excl);
	if (fence)
		describe_fence(fence, "Exclusive", m);
	rcu_read_unlock();
}