Example #1
0
bool
TaskAutoPilot::update_computer(TaskAccessor& task,
                               const AircraftState& state)
{
    if (!far_from_target(task, state)) {
        OnClose();
        return do_advance(task);
    }

    advance_if_required(task);

    return !has_finished(task);
}
Example #2
0
bool
TaskAutoPilot::update_computer(TaskAccessor& task,
                               const AIRCRAFT_STATE& state)
{
  if (!far_from_target(task, state)) {
    on_close();
    return do_advance(task);
  }

  advance_if_required(task);

  return !has_finished(task);
}
void AmTrackDataView::DrawOn(BRect clip, BView* view)
{
	view->SetHighColor( Prefs().Color(AM_DATA_BG_C) );
	view->FillRect(clip);
	if (mHeadBackground) mHeadBackground->DrawAllOn(view, clip);

	if (!mTarget) return;

	// READ SONG BLOCK
	#ifdef AM_TRACE_LOCKS
	printf("AmTrackDataView::DrawOn() read lock\n");
	#endif
	const AmSong*	song = mSongRef.ReadLock();
	const AmTrack*	track = song ? song->Track(mTrackWinProps.OrderedTrackAt(0)) : 0;
	if (track) {
		mOrderedSaturation = mTrackWinProps.OrderedSaturation();
		mShadowSaturation = mTrackWinProps.ShadowSaturation();
		PreDrawEventsOn(clip, view, track);
		if (mShadowSaturation > 0) DrawShadowEvents(clip, view, song);
		if (mOrderedSaturation > 0) DrawOrderedEvents(clip, view, song);
		DrawPrimaryEvents(clip, view, track);
		PostDrawEventsOn(clip, view, track);
	}
	mSongRef.ReadUnlock(song);
	// END READ SONG BLOCK

	// WRITE TOOL BLOCK
	AmTool*		tool = mActiveTool.WriteLock();
	if (tool) tool->DrawOn(view, clip);
	mActiveTool.WriteUnlock(tool);
	// END WRITE TOOL BLOCK
	
	/* Tool grapahics -- clean up any previous graphics that are finished,
	 * and let everyone draw.
	 */
	while (has_finished(mPrevToolGraphics)) ;
	for (uint32 k = 0; k < mPrevToolGraphics.size(); k++)
		mPrevToolGraphics[k]->DrawOn(view, clip);
	if (mToolGraphic) mToolGraphic->DrawOn(view, clip);

	/* Draw the song position.
	 */
	if (mSongPosition >= 0) {
		view->SetHighColor(0, 0, 0);
		view->StrokeLine( BPoint(mSongPosition, clip.top), BPoint(mSongPosition, clip.bottom) );
	}

	/* And finally, the transparent tool controls draw over everyone else.
	 */
	if (mToolControls) mToolControls->DrawOn(view, clip);
}
Example #4
0
bool
TaskAutoPilot::do_advance(TaskAccessor& task)
{
    if (task.is_ordered() && (awp==0)) {
        awp++;
    }
    awp++;
    if (has_finished(task))
        return false;
    task.setActiveTaskPoint(awp);
    get_awp(task);

    return true;
}
/****** test_sge_lock_multiple/thread_function() *********************************
*  NAME
*     thread_function() -- Thread function to execute 
*
*  SYNOPSIS
*     static void* thread_function(void *anArg) 
*
*  FUNCTION
*     Acquire multiple locks and sleep. Release the locks. After each 'sge_lock()'
*     and 'sge_unlock()' sleep to increase the probability of interlocked execution. 
*     Note that we deliberately test the boundaries of 'sge_locktype_t'.
*
*  INPUTS
*     void *anArg - thread function arguments 
*
*  RESULT
*     static void* - none
*
*  SEE ALSO
*     test_sge_lock_multiple/get_thrd_func()
*******************************************************************************/
static void *thread_function(void *anArg)
{
   struct timeval before;
   struct timeval after;
   double time_new;
   int i;
   int max = 1000000;
   int test = 257;
   int result;

   DENTER(TOP_LAYER, "thread_function");

   has_finished("start",0.0);
 
   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      result = test +1;
      test = result +1;
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("variable access", time_new);

   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      GET_SPECIFIC(state_t, state, state_init, state_key, "test_sge_lock_multiple");
      state->value2 = state->value +1;
      state->value = state->value2 +1;
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("thread local   ", time_new);
  
   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      pthread_once(&log_once, log_once_init);
      {
        GET_SPECIFIC(state_t, state, state_init, state_key, "test_sge_lock_multiple");
         state->value2 = state->value +1;
         state->value = state->value2 +1;
      }
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("thread local once ", time_new);
   
   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      sge_mutex_lock("mutex", SGE_FUNC, __LINE__, &mutex);
      result = test +1;
      test = result +1;
      sge_mutex_unlock("mutex", SGE_FUNC, __LINE__, &mutex);
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("mutex          ", time_new);

   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      SGE_LOCK(LOCK_GLOBAL, LOCK_READ);
      result = test +1;
      test = result +1;
      SGE_UNLOCK(LOCK_GLOBAL, LOCK_READ);
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("read lock      ", time_new);

   gettimeofday(&before, NULL); 
   for (i = 0; i < max; i++) {
      SGE_LOCK(LOCK_GLOBAL, LOCK_WRITE);
      result = test +1;
      test = result +1;
      SGE_UNLOCK(LOCK_GLOBAL, LOCK_WRITE);
   }
   gettimeofday(&after, NULL);

   time_new = after.tv_usec - before.tv_usec;
   time_new = after.tv_sec - before.tv_sec + (time_new/1000000);

   has_finished("write lock     ", time_new);

 
   DEXIT;
   return (void *)NULL;
} /* thread_function */