Changeset 150
- Timestamp:
- Jan 26, 2011, 7:58:27 PM (14 years ago)
- Location:
- MicroThreading
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r149 r150 39 39 </Item2> 40 40 </RequiredPackages> 41 <Units Count="5 1">41 <Units Count="57"> 42 42 <Unit0> 43 43 <Filename Value="Demo.lpr"/> 44 44 <IsPartOfProject Value="True"/> 45 45 <UnitName Value="Demo"/> 46 <IsVisibleTab Value="True"/>47 <EditorIndex Value="1"/>48 46 <WindowIndex Value="0"/> 49 47 <TopLine Value="1"/> 50 <CursorPos X="10" Y="7"/> 51 <UsageCount Value="58"/> 52 <Loaded Value="True"/> 48 <CursorPos X="5" Y="9"/> 49 <UsageCount Value="59"/> 53 50 </Unit0> 54 51 <Unit1> … … 58 55 <ResourceBaseClass Value="Form"/> 59 56 <UnitName Value="UMainForm"/> 57 <IsVisibleTab Value="True"/> 60 58 <EditorIndex Value="0"/> 61 59 <WindowIndex Value="0"/> 62 <TopLine Value=" 1"/>63 <CursorPos X="2 0" Y="226"/>64 <UsageCount Value="5 8"/>60 <TopLine Value="249"/> 61 <CursorPos X="22" Y="267"/> 62 <UsageCount Value="59"/> 65 63 <Loaded Value="True"/> 66 64 <LoadedDesigner Value="True"/> … … 69 67 <Filename Value="../UMicroThreading.pas"/> 70 68 <UnitName Value="UMicroThreading"/> 71 <EditorIndex Value=" 3"/>72 <WindowIndex Value="0"/> 73 <TopLine Value=" 352"/>74 <CursorPos X="1" Y=" 367"/>75 <UsageCount Value="3 2"/>69 <EditorIndex Value="1"/> 70 <WindowIndex Value="0"/> 71 <TopLine Value="271"/> 72 <CursorPos X="1" Y="286"/> 73 <UsageCount Value="33"/> 76 74 <Loaded Value="True"/> 77 75 </Unit2> … … 80 78 <UnitName Value="Forms"/> 81 79 <WindowIndex Value="0"/> 82 <TopLine Value=" 1310"/>83 <CursorPos X=" 15" Y="1327"/>84 <UsageCount Value=" 8"/>80 <TopLine Value="55"/> 81 <CursorPos X="3" Y="70"/> 82 <UsageCount Value="10"/> 85 83 </Unit3> 86 84 <Unit4> … … 110 108 <Filename Value="../../ExceptionLogger/UExceptionLogger.pas"/> 111 109 <UnitName Value="UExceptionLogger"/> 112 <EditorIndex Value="4"/>113 110 <WindowIndex Value="0"/> 114 111 <TopLine Value="1"/> 115 112 <CursorPos X="1" Y="8"/> 116 113 <UsageCount Value="10"/> 117 <Loaded Value="True"/>118 114 <DefaultSyntaxHighlighter Value="Delphi"/> 119 115 </Unit7> … … 146 142 <Unit11> 147 143 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/inc/systemh.inc"/> 148 <EditorIndex Value="2"/>149 144 <WindowIndex Value="0"/> 150 145 <TopLine Value="479"/> 151 146 <CursorPos X="3" Y="494"/> 152 147 <UsageCount Value="11"/> 153 <Loaded Value="True"/>154 148 </Unit11> 155 149 <Unit12> … … 177 171 <Filename Value="../../../../lazarus/lcl/include/control.inc"/> 178 172 <WindowIndex Value="0"/> 179 <TopLine Value=" 2271"/>180 <CursorPos X="1 9" Y="2274"/>173 <TopLine Value="1670"/> 174 <CursorPos X="1" Y="1685"/> 181 175 <UsageCount Value="11"/> 182 176 </Unit15> … … 198 192 <Unit18> 199 193 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/objpas/classes/classesh.inc"/> 200 <EditorIndex Value="6"/> 201 <WindowIndex Value="0"/> 202 <TopLine Value="1425"/> 203 <CursorPos X="25" Y="1443"/> 194 <WindowIndex Value="0"/> 195 <TopLine Value="1823"/> 196 <CursorPos X="3" Y="1838"/> 204 197 <UsageCount Value="12"/> 205 <Loaded Value="True"/>206 198 </Unit18> 207 199 <Unit19> 208 200 <Filename Value="../../../../lazarus/lcl/include/customform.inc"/> 209 201 <WindowIndex Value="0"/> 210 <TopLine Value=" 861"/>211 <CursorPos X="1" Y=" 878"/>212 <UsageCount Value=" 9"/>202 <TopLine Value="1348"/> 203 <CursorPos X="1" Y="1363"/> 204 <UsageCount Value="10"/> 213 205 </Unit19> 214 206 <Unit20> … … 414 406 <Filename Value="../UPlatform.pas"/> 415 407 <UnitName Value="UPlatform"/> 416 <EditorIndex Value=" 7"/>408 <EditorIndex Value="3"/> 417 409 <WindowIndex Value="0"/> 418 410 <TopLine Value="1"/> 419 411 <CursorPos X="24" Y="9"/> 420 <UsageCount Value="1 2"/>412 <UsageCount Value="13"/> 421 413 <Loaded Value="True"/> 422 414 </Unit48> … … 431 423 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/unix/sysutils.pp"/> 432 424 <UnitName Value="sysutils"/> 433 <EditorIndex Value="5"/>434 425 <WindowIndex Value="0"/> 435 426 <TopLine Value="1"/> 436 427 <CursorPos X="1" Y="1"/> 437 428 <UsageCount Value="10"/> 429 </Unit50> 430 <Unit51> 431 <Filename Value="../../../../lazarus/lcl/interfaces/gtk2/gtk2widgetset.inc"/> 432 <EditorIndex Value="2"/> 433 <WindowIndex Value="0"/> 434 <TopLine Value="2380"/> 435 <CursorPos X="30" Y="2390"/> 436 <UsageCount Value="10"/> 438 437 <Loaded Value="True"/> 439 </Unit50> 438 </Unit51> 439 <Unit52> 440 <Filename Value="/usr/share/fpcsrc/2.4.0/rtl/objpas/classes/classes.inc"/> 441 <WindowIndex Value="0"/> 442 <TopLine Value="150"/> 443 <CursorPos X="55" Y="162"/> 444 <UsageCount Value="10"/> 445 </Unit52> 446 <Unit53> 447 <Filename Value="../../../../lazarus/lcl/include/wincontrol.inc"/> 448 <WindowIndex Value="0"/> 449 <TopLine Value="5227"/> 450 <CursorPos X="1" Y="5242"/> 451 <UsageCount Value="10"/> 452 </Unit53> 453 <Unit54> 454 <Filename Value="../../../../lazarus/lcl/lclmessageglue.pas"/> 455 <UnitName Value="LCLMessageGlue"/> 456 <WindowIndex Value="0"/> 457 <TopLine Value="102"/> 458 <CursorPos X="1" Y="121"/> 459 <UsageCount Value="10"/> 460 </Unit54> 461 <Unit55> 462 <Filename Value="../../../../lazarus/lcl/interfaces/gtk2/gtk2proc.inc"/> 463 <WindowIndex Value="0"/> 464 <TopLine Value="3515"/> 465 <CursorPos X="1" Y="3531"/> 466 <UsageCount Value="10"/> 467 </Unit55> 468 <Unit56> 469 <Filename Value="../../../../lazarus/lcl/interfaces/gtk2/gtk2callback.inc"/> 470 <WindowIndex Value="0"/> 471 <TopLine Value="1159"/> 472 <CursorPos X="1" Y="1174"/> 473 <UsageCount Value="10"/> 474 </Unit56> 440 475 </Units> 441 476 <JumpHistory Count="30" HistoryIndex="29"> 442 477 <Position1> 443 478 <Filename Value="../UMicroThreading.pas"/> 444 <Caret Line=" 524" Column="1" TopLine="509"/>479 <Caret Line="308" Column="1" TopLine="284"/> 445 480 </Position1> 446 481 <Position2> 447 482 <Filename Value="../UMicroThreading.pas"/> 448 <Caret Line=" 530" Column="28" TopLine="515"/>483 <Caret Line="309" Column="1" TopLine="285"/> 449 484 </Position2> 450 485 <Position3> 451 486 <Filename Value="../UMicroThreading.pas"/> 452 <Caret Line=" 547" Column="1" TopLine="532"/>487 <Caret Line="310" Column="1" TopLine="286"/> 453 488 </Position3> 454 489 <Position4> 455 490 <Filename Value="../UMicroThreading.pas"/> 456 <Caret Line=" 570" Column="1" TopLine="555"/>491 <Caret Line="312" Column="1" TopLine="288"/> 457 492 </Position4> 458 493 <Position5> 459 494 <Filename Value="../UMicroThreading.pas"/> 460 <Caret Line=" 661" Column="1" TopLine="646"/>495 <Caret Line="315" Column="1" TopLine="291"/> 461 496 </Position5> 462 497 <Position6> 463 498 <Filename Value="../UMicroThreading.pas"/> 464 <Caret Line=" 662" Column="1" TopLine="646"/>499 <Caret Line="338" Column="1" TopLine="323"/> 465 500 </Position6> 466 501 <Position7> 467 502 <Filename Value="../UMicroThreading.pas"/> 468 <Caret Line=" 663" Column="1" TopLine="646"/>503 <Caret Line="218" Column="1" TopLine="203"/> 469 504 </Position7> 470 505 <Position8> 471 506 <Filename Value="../UMicroThreading.pas"/> 472 <Caret Line=" 570" Column="1" TopLine="555"/>507 <Caret Line="219" Column="1" TopLine="203"/> 473 508 </Position8> 474 509 <Position9> 475 510 <Filename Value="../UMicroThreading.pas"/> 476 <Caret Line=" 571" Column="1" TopLine="555"/>511 <Caret Line="360" Column="1" TopLine="345"/> 477 512 </Position9> 478 513 <Position10> 479 514 <Filename Value="../UMicroThreading.pas"/> 480 <Caret Line=" 572" Column="1" TopLine="555"/>515 <Caret Line="290" Column="25" TopLine="275"/> 481 516 </Position10> 482 517 <Position11> 483 518 <Filename Value="../UMicroThreading.pas"/> 484 <Caret Line=" 573" Column="1" TopLine="555"/>519 <Caret Line="291" Column="28" TopLine="276"/> 485 520 </Position11> 486 521 <Position12> 487 522 <Filename Value="../UMicroThreading.pas"/> 488 <Caret Line=" 574" Column="1" TopLine="555"/>523 <Caret Line="286" Column="1" TopLine="276"/> 489 524 </Position12> 490 525 <Position13> 491 526 <Filename Value="../UMicroThreading.pas"/> 492 <Caret Line=" 575" Column="1" TopLine="555"/>527 <Caret Line="301" Column="1" TopLine="277"/> 493 528 </Position13> 494 529 <Position14> 495 530 <Filename Value="../UMicroThreading.pas"/> 496 <Caret Line="2 0" Column="3" TopLine="1"/>531 <Caret Line="286" Column="1" TopLine="277"/> 497 532 </Position14> 498 533 <Position15> 499 534 <Filename Value="../UMicroThreading.pas"/> 500 <Caret Line=" 573" Column="1" TopLine="558"/>535 <Caret Line="287" Column="1" TopLine="277"/> 501 536 </Position15> 502 537 <Position16> 503 538 <Filename Value="../UMicroThreading.pas"/> 504 <Caret Line=" 664" Column="1" TopLine="649"/>539 <Caret Line="288" Column="1" TopLine="277"/> 505 540 </Position16> 506 541 <Position17> 507 542 <Filename Value="../UMicroThreading.pas"/> 508 <Caret Line=" 665" Column="1" TopLine="649"/>543 <Caret Line="301" Column="1" TopLine="277"/> 509 544 </Position17> 510 545 <Position18> 511 546 <Filename Value="../UMicroThreading.pas"/> 512 <Caret Line=" 666" Column="1" TopLine="649"/>547 <Caret Line="302" Column="1" TopLine="278"/> 513 548 </Position18> 514 549 <Position19> 515 550 <Filename Value="../UMicroThreading.pas"/> 516 <Caret Line=" 573" Column="1" TopLine="558"/>551 <Caret Line="303" Column="1" TopLine="279"/> 517 552 </Position19> 518 553 <Position20> 519 554 <Filename Value="../UMicroThreading.pas"/> 520 <Caret Line=" 574" Column="1" TopLine="558"/>555 <Caret Line="304" Column="1" TopLine="280"/> 521 556 </Position20> 522 557 <Position21> 523 558 <Filename Value="../UMicroThreading.pas"/> 524 <Caret Line=" 575" Column="1" TopLine="558"/>559 <Caret Line="305" Column="1" TopLine="281"/> 525 560 </Position21> 526 561 <Position22> 527 562 <Filename Value="../UMicroThreading.pas"/> 528 <Caret Line=" 576" Column="1" TopLine="558"/>563 <Caret Line="306" Column="1" TopLine="282"/> 529 564 </Position22> 530 565 <Position23> 531 566 <Filename Value="../UMicroThreading.pas"/> 532 <Caret Line=" 577" Column="1" TopLine="558"/>567 <Caret Line="308" Column="1" TopLine="284"/> 533 568 </Position23> 534 569 <Position24> 535 570 <Filename Value="../UMicroThreading.pas"/> 536 <Caret Line=" 578" Column="1" TopLine="558"/>571 <Caret Line="309" Column="1" TopLine="285"/> 537 572 </Position24> 538 573 <Position25> 539 574 <Filename Value="../UMicroThreading.pas"/> 540 <Caret Line=" 20" Column="16" TopLine="1"/>575 <Caret Line="310" Column="1" TopLine="286"/> 541 576 </Position25> 542 577 <Position26> 543 <Filename Value="../ ../ExceptionLogger/UExceptionLogger.pas"/>544 <Caret Line=" 15" Column="8" TopLine="1"/>578 <Filename Value="../UMicroThreading.pas"/> 579 <Caret Line="311" Column="1" TopLine="287"/> 545 580 </Position26> 546 581 <Position27> 547 582 <Filename Value="../UMicroThreading.pas"/> 548 <Caret Line=" 14" Column="15" TopLine="1"/>583 <Caret Line="313" Column="1" TopLine="289"/> 549 584 </Position27> 550 585 <Position28> 551 <Filename Value=" Demo.lpr"/>552 <Caret Line=" 8" Column="34" TopLine="1"/>586 <Filename Value="../UMicroThreading.pas"/> 587 <Caret Line="316" Column="1" TopLine="292"/> 553 588 </Position28> 554 589 <Position29> 555 590 <Filename Value="../UMicroThreading.pas"/> 556 <Caret Line=" 573" Column="1" TopLine="558"/>591 <Caret Line="339" Column="1" TopLine="324"/> 557 592 </Position29> 558 593 <Position30> 559 594 <Filename Value="../UMicroThreading.pas"/> 560 <Caret Line=" 649" Column="11" TopLine="649"/>595 <Caret Line="286" Column="1" TopLine="271"/> 561 596 </Position30> 562 597 </JumpHistory> … … 596 631 </CompilerOptions> 597 632 <Debugging> 598 <BreakPoints Count=" 6">633 <BreakPoints Count="1"> 599 634 <Item1> 600 <Source Value="../ Coroutine.pas"/>601 <Line Value=" 110"/>635 <Source Value="../UMicroThreading.pas"/> 636 <Line Value="285"/> 602 637 </Item1> 603 <Item2>604 <Source Value="../Coroutine.pas"/>605 <Line Value="222"/>606 </Item2>607 <Item3>608 <Source Value="../Coroutine.pas"/>609 <Line Value="257"/>610 </Item3>611 <Item4>612 <Source Value="../Coroutine.pas"/>613 <Line Value="145"/>614 </Item4>615 <Item5>616 <Source Value="../UMicroThreading.pas"/>617 <Line Value="560"/>618 </Item5>619 <Item6>620 <Source Value="../UMicroThreading.pas"/>621 <Line Value="540"/>622 </Item6>623 638 </BreakPoints> 624 639 <Exceptions Count="3"> -
MicroThreading/Demo/Demo.lpr
r149 r150 4 4 5 5 uses 6 {$IFDEF UNIX}{$IFDEF UseCThreads} 6 {$IFDEF UNIX} 7 //{$IFDEF UseCThreads} 7 8 cthreads, 8 {$ENDIF}{$ENDIF} 9 //{$ENDIF} 10 {$ENDIF} 9 11 Interfaces, // this includes the LCL widgetset 10 12 Forms, UMainForm, MicroThreading; -
MicroThreading/Demo/UMainForm.lfm
r149 r150 39 39 Top = 37 40 40 Width = 140 41 Caption = 'Clear microthreads'41 Caption = 'Clear jobs' 42 42 OnClick = ButtonClearMicroThreadsClick 43 43 TabOrder = 1 … … 69 69 ScrollBars = ssAutoBoth 70 70 TabOrder = 3 71 end 72 object Button1: TButton 73 Left = 14 74 Height = 25 75 Top = 94 76 Width = 75 77 Caption = 'Clear memo' 78 OnClick = Button1Click 79 TabOrder = 4 71 80 end 72 81 end … … 242 251 end 243 252 object Label2: TLabel 244 Left = 78253 Left = 102 245 254 Height = 14 246 255 Top = 135 247 Width = 38248 Caption = ' Label2'256 Width = 13 257 Caption = ' ' 249 258 ParentColor = False 250 259 end … … 257 266 OnClick = Button2Click 258 267 TabOrder = 2 268 end 269 object Label11: TLabel 270 Left = 15 271 Height = 14 272 Top = 135 273 Width = 81 274 Caption = 'Precision time:' 275 ParentColor = False 259 276 end 260 277 end -
MicroThreading/Demo/UMainForm.pas
r149 r150 14 14 15 15 TMainForm = class(TForm) 16 Button1: TButton; 16 17 Button2: TButton; 17 18 ButtonAddWorkers: TButton; … … 24 25 Label1: TLabel; 25 26 Label10: TLabel; 27 Label11: TLabel; 26 28 Label2: TLabel; 27 29 Label3: TLabel; … … 42 44 TimerRedraw: TTimer; 43 45 TimerSchedulerStart: TTimer; 46 procedure Button1Click(Sender: TObject); 44 47 procedure ButtonSchedulerStartStopClick(Sender: TObject); 45 48 procedure Button2Click(Sender: TObject); … … 87 90 if ButtonSchedulerStartStop.Caption = 'Start scheduler' then begin 88 91 ButtonSchedulerStartStop.Caption := 'Stop scheduler'; 89 Memo1.Clear;92 Scheduler.ThreadPoolSize := SpinEdit2.Value; 90 93 Scheduler.Active := True; 91 94 end else begin … … 93 96 Scheduler.Active := False; 94 97 end; 98 end; 99 100 procedure TMainForm.Button1Click(Sender: TObject); 101 begin 102 Memo1.Clear; 95 103 end; 96 104 … … 191 199 procedure TMainForm.FormClose(Sender: TObject; var CloseAction: TCloseAction); 192 200 begin 201 Scheduler.Active := False; 193 202 end; 194 203 -
MicroThreading/UMicroThreading.pas
r149 r150 275 275 mov eax, StaticMicroThread 276 276 mov edx, [eax].TMicroThread.FStackPointer 277 mov ecx, esp 277 278 mov esp, edx 278 279 push ebp // remember bp on micro thread stack for read back 280 push ecx 279 281 mov edx, [eax].TMicroThread.FBasePointer 280 282 mov ebp, edx … … 282 284 StaticMicroThread.Execute; 283 285 asm 286 pop edx 284 287 pop ebp 288 mov esp, edx 285 289 end; 286 290 //FSelected.Method(FSelected); 287 StaticManager := FCurrentMicroThread.FManager;291 (* StaticManager := FCurrentMicroThread.FManager; 288 292 asm 289 293 // Restore FScheduler stack … … 294 298 mov ebp, edx 295 299 end; 300 *) 296 301 FCurrentMicroThread.FManager := nil; 297 302 FCurrentMicroThread.FExecutionEndTime := CurrentTime; … … 561 566 try 562 567 FThreadPoolLock.Acquire; 568 FThreadPool.OwnsObjects := False; 563 569 FThreadPool.Delete(FThreadPool.IndexOf(Sender)); 570 FThreadPool.OwnsObjects := True; 564 571 finally 565 572 FThreadPoolLock.Release;
Note:
See TracChangeset
for help on using the changeset viewer.