Ejemplo n.º 1
0
void dgThreads::DoWork(dgInt32 mythreadIndex)
{
  dgWorkerThread* job;

#ifdef _WIN32
#ifndef __USE_DOUBLE_PRECISION__
  dgUnsigned32 controlWorld;
  controlWorld = dgControlFP (0xffffffff, 0);
  dgControlFP(_PC_53, _MCW_PC);
#endif
#endif

  if (!m_getPerformanceCount)
  {
    while (GetWork(&job))
    {
      job->ThreadExecute();
      dgInterlockedDecrement(&m_workInProgress);
    }
  }
  else
  {
    while (GetWork(&job))
    {
      dgUnsigned32 ticks = m_getPerformanceCount();

      job->ThreadExecute();
      dgInterlockedDecrement(&m_workInProgress);

      m_localData[mythreadIndex].m_ticks += (m_getPerformanceCount() - ticks);
    }
  }

#ifdef _WIN32
#ifndef __USE_DOUBLE_PRECISION__
  dgControlFP(controlWorld, _MCW_PC);
#endif
#endif

}
Ejemplo n.º 2
0
void NrpTester::AddWork( IWorkingModule& module, bool toFront )
{
	//модуль не закончен и этого модуля нет в списке запланированных
	if( (int)module[ ERRORNUMBER ] > 0 && GetWork( (NrpText)module[ NAME ] ) == NULL )
	{
		if( toFront )
			works_.insert( &module, 0 );
		else
			works_.push_back( &module );

		module.AddUser( *this );
	}

	_self[ WORKNUMBER ] = static_cast< int >( works_.size() );
}
Ejemplo n.º 3
0
//-------------------------------------------------------------------------------------------------
void JobManager::WorkThread( int slot ) {

	while(1) {
		Job *job = GetWork();

		if( job ) {
			ExecuteJob( job );
		}

		if( stop_threads ) {
			break;
		}
	}
	
}
Ejemplo n.º 4
0
//==============================================================
void *ObjGetVar(sOBJ *obj, int size)
//--------------------------------------------------------------
// ワーク取得
//--------------------------------------------------------------
// in:	obj  = ハンドル
//		size = データサイズ
//--------------------------------------------------------------
// out:	取得したポインタ
//==============================================================
{
	if(obj->var == NULL)
	{
		obj->var = GetWork(size, "obj_var");
	}
	return obj->var;
}
Ejemplo n.º 5
0
void*	evaluate(void)
{
   int		ulx, uly, lrx, lry;
   int		i, j, region_size, len0, len1;
   char 	*region,*aux, *pgrid;
   struct work_t *WorkToDo;
  
   while (( WorkToDo = GetWork()) != NULL) {
      /* Apenas para simplificar a visualização do código, copia para variáveis locais */
     ulx = WorkToDo->ulx;
     uly = WorkToDo->uly;
     lrx = WorkToDo->lrx;
     lry = WorkToDo->lry;
 
     region_size = (lrx - ulx + 1) * (lry - uly +1);
     region = (char *) malloc( sizeof(char) * region_size);
   
     if (region == NULL) {
        printf("Memory allocation error on evaluate (region)...\n");
        exit(0);
     }
     
     aux = region;   
     for(i = uly ; i <= lry ; i++)
        for(j =ulx ; j <=lrx; j ++)
           *aux++=xy2color(translate_x + scale_x*j,
                           translate_y + scale_y*i);

     len0 = lrx - ulx + 1;
     len1 = lry - uly + 1;
     pgrid = grid + (IMAGE_SIZE * uly + ulx);
   
     aux = region;

     for (i = 0; i < len1; ++i) {
         memcpy(pgrid, aux, len0); 
         aux += len0;
         pgrid += IMAGE_SIZE;
     }
    free(region);
  } /* Final do while */
  pthread_exit(0);
}  
Ejemplo n.º 6
0
bool StratumProtocol::GetWork(WorkBlob& work)
{
	return GetWork(GlobalClient, work);
}
Ejemplo n.º 7
0
/* Route all traces
 * :
 *  1 if OK
 * -1 if escape (stop being routed) request
 * -2 if default memory allocation
 */
int PCB_EDIT_FRAME::Solve( wxDC* DC, int aLayersCount )
{
    int           current_net_code;
    int           row_source, col_source, row_target, col_target;
    int           success, nbsucces = 0, nbunsucces = 0;
    NETINFO_ITEM* net;
    bool          stop = false;
    wxString      msg;
    int           routedCount = 0;      // routed ratsnest count
    bool          two_sides = aLayersCount == 2;

    m_canvas->SetAbortRequest( false );

    s_Clearance = GetBoard()->GetDesignSettings().GetDefault()->GetClearance();

    // Prepare the undo command info
    s_ItemsListPicker.ClearListAndDeleteItems();  // Should not be necessary, but...

    // go until no more work to do
    GetWork( &row_source, &col_source, &current_net_code,
             &row_target, &col_target, &pt_cur_ch ); // First net to route.

    for( ; row_source != ILLEGAL; GetWork( &row_source, &col_source,
                                           &current_net_code, &row_target,
                                           &col_target,
                                           &pt_cur_ch ) )
    {
        // Test to stop routing ( escape key pressed )
        wxYield();

        if( m_canvas->GetAbortRequest() )
        {
            if( IsOK( this, _( "Abort routing?" ) ) )
            {
                success = STOP_FROM_ESC;
                stop    = true;
                break;
            }
            else
            {
                m_canvas->SetAbortRequest( false );
            }
        }

        EraseMsgBox();

        routedCount++;
        net = GetBoard()->FindNet( current_net_code );

        if( net )
        {
            msg.Printf( wxT( "[%8.8s]" ), GetChars( net->GetNetname() ) );
            AppendMsgPanel( wxT( "Net route" ), msg, BROWN );
            msg.Printf( wxT( "%d / %d" ), routedCount, RoutingMatrix.m_RouteCount );
            AppendMsgPanel( wxT( "Activity" ), msg, BROWN );
        }

        segm_oX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_source);
        segm_oY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_source);
        segm_fX = GetBoard()->GetBoundingBox().GetX() + (RoutingMatrix.m_GridRouting * col_target);
        segm_fY = GetBoard()->GetBoundingBox().GetY() + (RoutingMatrix.m_GridRouting * row_target);

        // Draw segment.
        GRLine( m_canvas->GetClipBox(), DC,
                segm_oX, segm_oY, segm_fX, segm_fY,
                0, WHITE );
        pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );
        pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_OR | GR_HIGHLIGHT );

        success = Autoroute_One_Track( this, DC,
                                       two_sides, row_source, col_source,
                                       row_target, col_target, pt_cur_ch );

        switch( success )
        {
        case NOSUCCESS:
            pt_cur_ch->m_Status |= CH_UNROUTABLE;
            nbunsucces++;
            break;

        case STOP_FROM_ESC:
            stop = true;
            break;

        case ERR_MEMORY:
            stop = true;
            break;

        default:
            nbsucces++;
            break;
        }

        msg.Printf( wxT( "%d" ), nbsucces );
        AppendMsgPanel( wxT( "OK" ), msg, GREEN );
        msg.Printf( wxT( "%d" ), nbunsucces );
        AppendMsgPanel( wxT( "Fail" ), msg, RED );
        msg.Printf( wxT( "  %d" ), GetBoard()->GetUnconnectedNetCount() );
        AppendMsgPanel( wxT( "Not Connected" ), msg, CYAN );

        // Delete routing from display.
        pt_cur_ch->m_PadStart->Draw( m_canvas, DC, GR_AND );
        pt_cur_ch->m_PadEnd->Draw( m_canvas, DC, GR_AND );

        if( stop )
            break;
    }

    SaveCopyInUndoList( s_ItemsListPicker, UR_UNSPECIFIED );
    s_ItemsListPicker.ClearItemsList(); // s_ItemsListPicker is no more owner of picked items

    return SUCCESS;
}
Ejemplo n.º 8
0
int WinEDA_PcbFrame::Solve(wxDC * DC, int two_sides)
{
int current_net_code;
int row_source, col_source, row_target, col_target;
int success, nbsucces = 0, nbunsucces = 0;
EQUIPOT * pt_equipot;
bool stop = FALSE;
wxString msg;
	
	DrawPanel->m_AbortRequest = FALSE;
	DrawPanel->m_AbortEnable = TRUE;

	Ncurrent = 0;
	MsgPanel->EraseMsgBox();
	msg.Printf( wxT("%d  "),m_Pcb->m_NbNoconnect);
	Affiche_1_Parametre(this, 72, wxT("NoConn"),msg,LIGHTCYAN);


	/* go until no more work to do */
	GetWork( &row_source, &col_source, &current_net_code,
			&row_target, &col_target, &pt_cur_ch ); // 1er chevelu a router

	for ( ; row_source != ILLEGAL; GetWork( &row_source, &col_source,
					&current_net_code, &row_target, &col_target, &pt_cur_ch ))
		{
		/* Tst demande d'arret de routage ( key ESCAPE actionnee ) */
		wxYield();
		if( DrawPanel->m_AbortRequest )
			{
			if ( IsOK(this, _("Abort routing?" )) )
				{
				success = STOP_FROM_ESC;
				stop = TRUE;
				break;
				}
			else DrawPanel->m_AbortRequest = 0;
			}

		Ncurrent++;
		pt_equipot = GetEquipot(m_Pcb, current_net_code);
		if( pt_equipot)
			{
			msg.Printf( wxT("[%8.8s]"),pt_equipot->m_Netname.GetData());
			Affiche_1_Parametre(this, 1, wxT("Net route"), msg,YELLOW);
			msg.Printf( wxT( "%d / %d"),Ncurrent, Ntotal);
			Affiche_1_Parametre(this, 12, wxT("Activity"), msg,YELLOW);
			}

		pt_cur_ch = pt_cur_ch;
		segm_oX = m_Pcb->m_BoundaryBox.m_Pos.x + (pas_route * col_source);
		segm_oY = m_Pcb->m_BoundaryBox.m_Pos.y + (pas_route * row_source);
		segm_fX = m_Pcb->m_BoundaryBox.m_Pos.x + (pas_route * col_target);
		segm_fY = m_Pcb->m_BoundaryBox.m_Pos.y + (pas_route * row_target);

		/* Affiche Liaison */
		GRLine(&DrawPanel->m_ClipBox, DC, segm_oX, segm_oY, segm_fX, segm_fY, WHITE | GR_XOR);
		pt_cur_ch->pad_start->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR | GR_SURBRILL);
		pt_cur_ch->pad_end->Draw(DrawPanel, DC, wxPoint(0,0), GR_OR|GR_SURBRILL);

		success = Route_1_Trace(this, DC, two_sides, row_source, col_source,
						row_target, col_target, pt_cur_ch );
		switch (success)
			{
			case NOSUCCESS:
				pt_cur_ch->status |= CH_UNROUTABLE;
				nbunsucces++;
				break;

			case STOP_FROM_ESC:
				stop = TRUE;
				break;

			case ERR_MEMORY:
				stop = TRUE;
				break;

			default:
				nbsucces++;
				break;
			}

		msg.Printf( wxT("%d  "),nbsucces);
		Affiche_1_Parametre(this, 61, wxT("Ok"),msg,LIGHTGREEN);
		msg.Printf( wxT("%d  "),nbunsucces);
		Affiche_1_Parametre(this, 66, wxT("Fail"),msg,LIGHTRED);
		msg.Printf( wxT("%d  "),m_Pcb->m_NbNoconnect);
		Affiche_1_Parametre(this, 72, wxT("NoConn"),msg,LIGHTCYAN);

		/* Effacement des affichages de routage sur l'ecran */
		pt_cur_ch->pad_start->Draw(DrawPanel, DC, wxPoint(0,0), GR_AND);
		pt_cur_ch->pad_end->Draw(DrawPanel, DC,wxPoint(0,0), GR_AND);

		if ( stop ) break;
		}

	DrawPanel->m_AbortEnable = FALSE;

	return(SUCCESS);
}