Changeset 153 for MicroThreading
- Timestamp:
- Jan 27, 2011, 10:56:06 AM (14 years ago)
- Location:
- MicroThreading
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r152 r153 39 39 </Item2> 40 40 </RequiredPackages> 41 <Units Count="6 1">41 <Units Count="62"> 42 42 <Unit0> 43 43 <Filename Value="Demo.lpr"/> … … 47 47 <TopLine Value="1"/> 48 48 <CursorPos X="5" Y="9"/> 49 <UsageCount Value="6 7"/>49 <UsageCount Value="68"/> 50 50 </Unit0> 51 51 <Unit1> … … 57 57 <EditorIndex Value="0"/> 58 58 <WindowIndex Value="0"/> 59 <TopLine Value=" 268"/>60 <CursorPos X="1 " Y="288"/>61 <UsageCount Value="6 7"/>59 <TopLine Value="1"/> 60 <CursorPos X="15" Y="67"/> 61 <UsageCount Value="68"/> 62 62 <Loaded Value="True"/> 63 63 <LoadedDesigner Value="True"/> … … 67 67 <UnitName Value="UMicroThreading"/> 68 68 <IsVisibleTab Value="True"/> 69 <EditorIndex Value=" 2"/>70 <WindowIndex Value="0"/> 71 <TopLine Value=" 272"/>72 <CursorPos X=" 23" Y="288"/>69 <EditorIndex Value="1"/> 70 <WindowIndex Value="0"/> 71 <TopLine Value="446"/> 72 <CursorPos X="6" Y="450"/> 73 73 <UsageCount Value="37"/> 74 74 <Loaded Value="True"/> … … 293 293 <Unit32> 294 294 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/> 295 <EditorIndex Value=" 6"/>296 <WindowIndex Value="0"/> 297 <TopLine Value="146 6"/>298 <CursorPos X=" 15" Y="1479"/>295 <EditorIndex Value="5"/> 296 <WindowIndex Value="0"/> 297 <TopLine Value="1467"/> 298 <CursorPos X="5" Y="1488"/> 299 299 <UsageCount Value="18"/> 300 300 <Loaded Value="True"/> … … 302 302 <Unit33> 303 303 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/win/tthread.inc"/> 304 <EditorIndex Value=" 7"/>304 <EditorIndex Value="6"/> 305 305 <WindowIndex Value="0"/> 306 306 <TopLine Value="52"/> 307 <CursorPos X="2 3" Y="55"/>307 <CursorPos X="25" Y="65"/> 308 308 <UsageCount Value="15"/> 309 309 <Loaded Value="True"/> … … 325 325 <Unit36> 326 326 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classes.inc"/> 327 <EditorIndex Value=" 8"/>328 <WindowIndex Value="0"/> 329 <TopLine Value=" 85"/>330 <CursorPos X=" 21" Y="107"/>327 <EditorIndex Value="7"/> 328 <WindowIndex Value="0"/> 329 <TopLine Value="124"/> 330 <CursorPos X="3" Y="126"/> 331 331 <UsageCount Value="18"/> 332 332 <Loaded Value="True"/> … … 341 341 <Unit38> 342 342 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/sysutils/osutilsh.inc"/> 343 <EditorIndex Value=" 3"/>343 <EditorIndex Value="2"/> 344 344 <WindowIndex Value="0"/> 345 345 <TopLine Value="14"/> … … 414 414 <Filename Value="../UPlatform.pas"/> 415 415 <UnitName Value="UPlatform"/> 416 <EditorIndex Value=" 10"/>416 <EditorIndex Value="9"/> 417 417 <WindowIndex Value="0"/> 418 418 <TopLine Value="1"/> 419 <CursorPos X=" 24" Y="9"/>419 <CursorPos X="14" Y="1"/> 420 420 <UsageCount Value="17"/> 421 421 <Loaded Value="True"/> … … 481 481 <Unit57> 482 482 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/lists.inc"/> 483 <EditorIndex Value=" 9"/>483 <EditorIndex Value="8"/> 484 484 <WindowIndex Value="0"/> 485 485 <TopLine Value="590"/> 486 486 <CursorPos X="14" Y="594"/> 487 <UsageCount Value="1 2"/>487 <UsageCount Value="13"/> 488 488 <Loaded Value="True"/> 489 489 </Unit57> 490 490 <Unit58> 491 491 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32callback.inc"/> 492 <EditorIndex Value=" 5"/>492 <EditorIndex Value="4"/> 493 493 <WindowIndex Value="0"/> 494 494 <TopLine Value="1086"/> 495 495 <CursorPos X="1" Y="1099"/> 496 <UsageCount Value="1 2"/>496 <UsageCount Value="13"/> 497 497 <Loaded Value="True"/> 498 498 </Unit58> … … 500 500 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/extctrls.pp"/> 501 501 <UnitName Value="ExtCtrls"/> 502 <EditorIndex Value="1"/>503 502 <WindowIndex Value="0"/> 504 503 <TopLine Value="357"/> 505 504 <CursorPos X="3" Y="370"/> 506 <UsageCount Value="12"/> 507 <Loaded Value="True"/> 505 <UsageCount Value="11"/> 508 506 </Unit59> 509 507 <Unit60> 510 508 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/customtimer.pas"/> 511 509 <UnitName Value="CustomTimer"/> 512 <EditorIndex Value=" 4"/>510 <EditorIndex Value="3"/> 513 511 <WindowIndex Value="0"/> 514 512 <TopLine Value="40"/> 515 513 <CursorPos X="17" Y="53"/> 516 <UsageCount Value="1 1"/>514 <UsageCount Value="12"/> 517 515 <Loaded Value="True"/> 518 516 </Unit60> 517 <Unit61> 518 <Filename Value="../ReadMe.txt"/> 519 <EditorIndex Value="10"/> 520 <WindowIndex Value="0"/> 521 <TopLine Value="1"/> 522 <CursorPos X="17" Y="14"/> 523 <UsageCount Value="10"/> 524 <Loaded Value="True"/> 525 <DefaultSyntaxHighlighter Value="None"/> 526 </Unit61> 519 527 </Units> 520 <JumpHistory Count="30" HistoryIndex="2 8">528 <JumpHistory Count="30" HistoryIndex="29"> 521 529 <Position1> 522 530 <Filename Value="../UMicroThreading.pas"/> 523 <Caret Line="2 99" Column="1" TopLine="280"/>531 <Caret Line="279" Column="19" TopLine="267"/> 524 532 </Position1> 525 533 <Position2> 526 534 <Filename Value="../UMicroThreading.pas"/> 527 <Caret Line=" 300" Column="1" TopLine="280"/>535 <Caret Line="295" Column="1" TopLine="270"/> 528 536 </Position2> 529 537 <Position3> 530 538 <Filename Value="../UMicroThreading.pas"/> 531 <Caret Line=" 301" Column="1" TopLine="280"/>539 <Caret Line="289" Column="1" TopLine="270"/> 532 540 </Position3> 533 541 <Position4> 534 542 <Filename Value="../UMicroThreading.pas"/> 535 <Caret Line=" 302" Column="1" TopLine="283"/>543 <Caret Line="290" Column="1" TopLine="270"/> 536 544 </Position4> 537 545 <Position5> 538 546 <Filename Value="../UMicroThreading.pas"/> 539 <Caret Line=" 465" Column="1" TopLine="452"/>547 <Caret Line="291" Column="1" TopLine="270"/> 540 548 </Position5> 541 549 <Position6> 542 550 <Filename Value="../UMicroThreading.pas"/> 543 <Caret Line=" 468" Column="1" TopLine="452"/>551 <Caret Line="292" Column="1" TopLine="270"/> 544 552 </Position6> 545 553 <Position7> 546 554 <Filename Value="../UMicroThreading.pas"/> 547 <Caret Line=" 469" Column="1" TopLine="452"/>555 <Caret Line="598" Column="50" TopLine="587"/> 548 556 </Position7> 549 557 <Position8> 550 558 <Filename Value="../UMicroThreading.pas"/> 551 <Caret Line=" 470" Column="1" TopLine="452"/>559 <Caret Line="291" Column="40" TopLine="278"/> 552 560 </Position8> 553 561 <Position9> 554 562 <Filename Value="../UMicroThreading.pas"/> 555 <Caret Line="2 26" Column="1" TopLine="213"/>563 <Caret Line="280" Column="1" TopLine="272"/> 556 564 </Position9> 557 565 <Position10> 558 566 <Filename Value="../UMicroThreading.pas"/> 559 <Caret Line=" 304" Column="1" TopLine="291"/>567 <Caret Line="288" Column="26" TopLine="272"/> 560 568 </Position10> 561 569 <Position11> 562 570 <Filename Value="../UMicroThreading.pas"/> 563 <Caret Line=" 312" Column="1" TopLine="291"/>571 <Caret Line="285" Column="35" TopLine="272"/> 564 572 </Position11> 565 573 <Position12> 566 574 <Filename Value="../UMicroThreading.pas"/> 567 <Caret Line=" 329" Column="1" TopLine="316"/>575 <Caret Line="288" Column="1" TopLine="272"/> 568 576 </Position12> 569 577 <Position13> 570 578 <Filename Value="../UMicroThreading.pas"/> 571 <Caret Line="2 27" Column="1" TopLine="214"/>579 <Caret Line="289" Column="1" TopLine="272"/> 572 580 </Position13> 573 581 <Position14> 574 582 <Filename Value="../UMicroThreading.pas"/> 575 <Caret Line="2 28" Column="1" TopLine="214"/>583 <Caret Line="290" Column="1" TopLine="272"/> 576 584 </Position14> 577 585 <Position15> 578 586 <Filename Value="../UMicroThreading.pas"/> 579 <Caret Line=" 351" Column="1" TopLine="338"/>587 <Caret Line="291" Column="1" TopLine="272"/> 580 588 </Position15> 581 589 <Position16> 582 590 <Filename Value="../UMicroThreading.pas"/> 583 <Caret Line=" 352" Column="1" TopLine="338"/>591 <Caret Line="292" Column="1" TopLine="272"/> 584 592 </Position16> 585 593 <Position17> 586 594 <Filename Value="../UMicroThreading.pas"/> 587 <Caret Line=" 350" Column="1" TopLine="338"/>595 <Caret Line="293" Column="1" TopLine="272"/> 588 596 </Position17> 589 597 <Position18> 590 598 <Filename Value="../UMicroThreading.pas"/> 591 <Caret Line=" 351" Column="35" TopLine="338"/>599 <Caret Line="296" Column="1" TopLine="274"/> 592 600 </Position18> 593 601 <Position19> 594 602 <Filename Value="../UMicroThreading.pas"/> 595 <Caret Line="2 79" Column="19" TopLine="267"/>603 <Caret Line="297" Column="1" TopLine="275"/> 596 604 </Position19> 597 605 <Position20> 598 606 <Filename Value="../UMicroThreading.pas"/> 599 <Caret Line="29 5" Column="1" TopLine="270"/>607 <Caret Line="298" Column="1" TopLine="276"/> 600 608 </Position20> 601 609 <Position21> 602 610 <Filename Value="../UMicroThreading.pas"/> 603 <Caret Line="2 89" Column="1" TopLine="270"/>611 <Caret Line="299" Column="1" TopLine="277"/> 604 612 </Position21> 605 613 <Position22> 606 614 <Filename Value="../UMicroThreading.pas"/> 607 <Caret Line=" 290" Column="1" TopLine="270"/>615 <Caret Line="471" Column="1" TopLine="458"/> 608 616 </Position22> 609 617 <Position23> 610 618 <Filename Value="../UMicroThreading.pas"/> 611 <Caret Line="2 91" Column="1" TopLine="270"/>619 <Caret Line="285" Column="32" TopLine="275"/> 612 620 </Position23> 613 621 <Position24> 614 <Filename Value="../ UMicroThreading.pas"/>615 <Caret Line=" 292" Column="1" TopLine="270"/>622 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/> 623 <Caret Line="1488" Column="37" TopLine="1467"/> 616 624 </Position24> 617 625 <Position25> 618 626 <Filename Value="../UMicroThreading.pas"/> 619 <Caret Line=" 598" Column="50" TopLine="587"/>627 <Caret Line="71" Column="5" TopLine="55"/> 620 628 </Position25> 621 629 <Position26> 622 630 <Filename Value="../UMicroThreading.pas"/> 623 <Caret Line=" 291" Column="40" TopLine="278"/>631 <Caret Line="125" Column="1" TopLine="110"/> 624 632 </Position26> 625 633 <Position27> 626 <Filename Value=" ../UMicroThreading.pas"/>627 <Caret Line=" 280" Column="1" TopLine="272"/>634 <Filename Value="UMainForm.pas"/> 635 <Caret Line="68" Column="29" TopLine="54"/> 628 636 </Position27> 629 637 <Position28> 630 638 <Filename Value="../UMicroThreading.pas"/> 631 <Caret Line=" 288" Column="26" TopLine="272"/>639 <Caret Line="566" Column="20" TopLine="561"/> 632 640 </Position28> 633 641 <Position29> 634 642 <Filename Value="../UMicroThreading.pas"/> 635 <Caret Line=" 285" Column="35" TopLine="272"/>643 <Caret Line="567" Column="23" TopLine="554"/> 636 644 </Position29> 637 645 <Position30> 638 646 <Filename Value="../UMicroThreading.pas"/> 639 <Caret Line=" 397" Column="18" TopLine="393"/>647 <Caret Line="579" Column="51" TopLine="560"/> 640 648 </Position30> 641 649 </JumpHistory> … … 655 663 <RangeChecks Value="True"/> 656 664 <OverflowChecks Value="True"/> 665 <StackChecks Value="True"/> 657 666 </Checks> 658 667 </CodeGeneration> … … 675 684 </CompilerOptions> 676 685 <Debugging> 677 <BreakPoints Count="4">678 <Item1>679 <Source Value="../UMicroThreading.pas"/>680 <Line Value="296"/>681 </Item1>682 <Item2>683 <Source Value="../UMicroThreading.pas"/>684 <Line Value="371"/>685 </Item2>686 <Item3>687 <Source Value="../UMicroThreading.pas"/>688 <Line Value="471"/>689 </Item3>690 <Item4>691 <Source Value="../UMicroThreading.pas"/>692 <Line Value="288"/>693 </Item4>694 </BreakPoints>695 686 <Watches Count="2"> 696 687 <Item1> -
MicroThreading/Demo/UMainForm.pas
r152 r153 66 66 private 67 67 procedure Worker(MicroThread: TMicroThread); 68 procedure WorkerDoWrite; 68 69 public 69 70 Iterations: Integer; … … 282 283 Q := 0; 283 284 while Q < 100 do Inc(Q); 285 Synchronize(WorkerDoWrite); 284 286 //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 285 287 // FloatToStr(ExecutionTime)); … … 291 293 end; 292 294 295 procedure TMainForm.WorkerDoWrite; 296 begin 297 Memo1.Lines.Add('.'); 298 end; 299 293 300 end. 294 301 -
MicroThreading/MicroThreading.lpk
r149 r153 17 17 <License Value="GNU/GPL"/> 18 18 <Version Minor="1"/> 19 <Files Count=" 3">19 <Files Count="4"> 20 20 <Item1> 21 21 <Filename Value="UMicroThreading.pas"/> … … 30 30 <UnitName Value="UPlatform"/> 31 31 </Item3> 32 <Item4> 33 <Filename Value="ReadMe.txt"/> 34 <Type Value="Binary"/> 35 </Item4> 32 36 </Files> 33 37 <Type Value="RunAndDesignTime"/> -
MicroThreading/UMicroThreading.pas
r152 r153 69 69 procedure Resume; 70 70 procedure Suspend; 71 procedure Synchronize(AMethod: TThreadMethod); 71 72 72 73 constructor Create(CreateSuspended: Boolean; … … 118 119 FCurrentMicroThread: TMicroThread; 119 120 FScheduler: TMicroThreadScheduler; 121 FThread: TMicroThreadThread; 120 122 function Execute(Count: Integer): Integer; 121 123 public 122 124 Id: Integer; 123 125 procedure Yield; 126 procedure Synchronize(AMethod: TThreadMethod); 124 127 constructor Create; 125 128 destructor Destroy; override; … … 332 335 end; 333 336 337 procedure TMicroThreadManager.Synchronize(AMethod: TThreadMethod); 338 begin 339 if Assigned(FThread) then 340 FThread.Synchronize(FThread, AMethod); 341 end; 342 334 343 constructor TMicroThreadManager.Create; 335 344 begin 336 345 FCurrentMicroThread := nil; 346 FThread := nil; 337 347 end; 338 348 … … 487 497 FSuspended := True; 488 498 //Yield; 499 end; 500 501 procedure TMicroThread.Synchronize(AMethod: TThreadMethod); 502 begin 503 FManager.Synchronize(AMethod); 489 504 end; 490 505 … … 538 553 FMainThreadManager.Free; 539 554 FThreadPool.Free; 555 FThreadPoolLock.Free; 540 556 FMicroThreads.Free; 541 557 FMicroThreadsLock.Free; … … 548 564 UpdateThreadPoolSize; 549 565 FState := ssRunning; 566 if FUseMainThread then 567 FMainThreadStarter.Enabled := True; 550 568 end; 551 569 … … 599 617 NewThread := TMicroThreadThread.Create(True); 600 618 NewThread.Manager.FScheduler := Self; 601 NewThread.Manager.Id := FThreadPool.Count; 619 NewThread.Manager.Id := FThreadPool.Count + 1; 620 NewThread.Manager.FThread := NewThread; 602 621 NewThread.OnTerminate := PoolThreadTerminated; 603 622 ThreadPool.Add(NewThread);
Note:
See TracChangeset
for help on using the changeset viewer.