Changeset 147 for MicroThreading/Demo
- Timestamp:
- Jan 26, 2011, 8:06:25 AM (14 years ago)
- Location:
- MicroThreading/Demo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r146 r147 42 42 </Item3> 43 43 </RequiredPackages> 44 <Units Count="4 4">44 <Units Count="46"> 45 45 <Unit0> 46 46 <Filename Value="Demo.lpr"/> … … 50 50 <TopLine Value="1"/> 51 51 <CursorPos X="1" Y="15"/> 52 <UsageCount Value="4 8"/>52 <UsageCount Value="49"/> 53 53 </Unit0> 54 54 <Unit1> … … 60 60 <EditorIndex Value="0"/> 61 61 <WindowIndex Value="0"/> 62 <TopLine Value=" 218"/>63 <CursorPos X="1 7" Y="230"/>64 <UsageCount Value="4 8"/>62 <TopLine Value="82"/> 63 <CursorPos X="1" Y="95"/> 64 <UsageCount Value="49"/> 65 65 <Loaded Value="True"/> 66 66 <LoadedDesigner Value="True"/> … … 69 69 <Filename Value="../UMicroThreading.pas"/> 70 70 <UnitName Value="UMicroThreading"/> 71 <IsVisibleTab Value="True"/> 72 <EditorIndex Value="1"/> 73 <WindowIndex Value="0"/> 74 <TopLine Value="259"/> 75 <CursorPos X="11" Y="278"/> 71 <EditorIndex Value="2"/> 72 <WindowIndex Value="0"/> 73 <TopLine Value="500"/> 74 <CursorPos X="1" Y="517"/> 76 75 <UsageCount Value="27"/> 77 76 <Loaded Value="True"/> … … 238 237 <Unit24> 239 238 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/sysutils/datih.inc"/> 240 <WindowIndex Value="0"/> 241 <TopLine Value="161"/> 242 <CursorPos X="11" Y="184"/> 239 <EditorIndex Value="4"/> 240 <WindowIndex Value="0"/> 241 <TopLine Value="106"/> 242 <CursorPos X="10" Y="119"/> 243 243 <UsageCount Value="16"/> 244 <Loaded Value="True"/> 244 245 </Unit24> 245 246 <Unit25> … … 296 297 <Unit32> 297 298 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/> 298 <WindowIndex Value="0"/> 299 <TopLine Value="1507"/> 300 <CursorPos X="3" Y="1469"/> 301 <UsageCount Value="13"/> 299 <EditorIndex Value="5"/> 300 <WindowIndex Value="0"/> 301 <TopLine Value="1504"/> 302 <CursorPos X="1" Y="1510"/> 303 <UsageCount Value="13"/> 304 <Loaded Value="True"/> 302 305 </Unit32> 303 306 <Unit33> … … 324 327 <Unit36> 325 328 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classes.inc"/> 329 <EditorIndex Value="6"/> 326 330 <WindowIndex Value="0"/> 327 331 <TopLine Value="109"/> 328 <CursorPos X="6" Y="115"/> 329 <UsageCount Value="13"/> 332 <CursorPos X="3" Y="111"/> 333 <UsageCount Value="13"/> 334 <Loaded Value="True"/> 330 335 </Unit36> 331 336 <Unit37> … … 378 383 <UsageCount Value="10"/> 379 384 </Unit43> 385 <Unit44> 386 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/include/spinedit.inc"/> 387 <EditorIndex Value="1"/> 388 <WindowIndex Value="0"/> 389 <TopLine Value="221"/> 390 <CursorPos X="1" Y="235"/> 391 <UsageCount Value="10"/> 392 <Loaded Value="True"/> 393 </Unit44> 394 <Unit45> 395 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32object.inc"/> 396 <IsVisibleTab Value="True"/> 397 <EditorIndex Value="3"/> 398 <WindowIndex Value="0"/> 399 <TopLine Value="387"/> 400 <CursorPos X="1" Y="400"/> 401 <UsageCount Value="10"/> 402 <Loaded Value="True"/> 403 </Unit45> 380 404 </Units> 381 <JumpHistory Count="30" HistoryIndex=" 19">405 <JumpHistory Count="30" HistoryIndex="29"> 382 406 <Position1> 383 407 <Filename Value="../UMicroThreading.pas"/> 384 <Caret Line=" 272" Column="1" TopLine="250"/>408 <Caret Line="579" Column="1" TopLine="566"/> 385 409 </Position1> 386 410 <Position2> 387 411 <Filename Value="../UMicroThreading.pas"/> 388 <Caret Line=" 273" Column="1" TopLine="251"/>412 <Caret Line="580" Column="1" TopLine="566"/> 389 413 </Position2> 390 414 <Position3> 391 415 <Filename Value="../UMicroThreading.pas"/> 392 <Caret Line=" 274" Column="1" TopLine="252"/>416 <Caret Line="581" Column="1" TopLine="566"/> 393 417 </Position3> 394 418 <Position4> 395 419 <Filename Value="../UMicroThreading.pas"/> 396 <Caret Line=" 397" Column="1" TopLine="384"/>420 <Caret Line="582" Column="1" TopLine="566"/> 397 421 </Position4> 398 422 <Position5> 399 423 <Filename Value="../UMicroThreading.pas"/> 400 <Caret Line=" 398" Column="1" TopLine="384"/>424 <Caret Line="583" Column="1" TopLine="566"/> 401 425 </Position5> 402 426 <Position6> 403 <Filename Value=" UMainForm.pas"/>404 <Caret Line=" 230" Column="17" TopLine="218"/>427 <Filename Value="../UMicroThreading.pas"/> 428 <Caret Line="584" Column="1" TopLine="566"/> 405 429 </Position6> 406 430 <Position7> 407 431 <Filename Value="../UMicroThreading.pas"/> 408 <Caret Line=" 256" Column="1" TopLine="243"/>432 <Caret Line="142" Column="26" TopLine="125"/> 409 433 </Position7> 410 434 <Position8> 411 <Filename Value=" ../UMicroThreading.pas"/>412 <Caret Line=" 259" Column="1" TopLine="243"/>435 <Filename Value="UMainForm.pas"/> 436 <Caret Line="95" Column="17" TopLine="87"/> 413 437 </Position8> 414 438 <Position9> 415 439 <Filename Value="../UMicroThreading.pas"/> 416 <Caret Line=" 262" Column="1" TopLine="243"/>440 <Caret Line="512" Column="3" TopLine="507"/> 417 441 </Position9> 418 442 <Position10> 419 <Filename Value=" ../UMicroThreading.pas"/>420 <Caret Line=" 263" Column="1" TopLine="243"/>443 <Filename Value="UMainForm.pas"/> 444 <Caret Line="95" Column="17" TopLine="87"/> 421 445 </Position10> 422 446 <Position11> 423 447 <Filename Value="../UMicroThreading.pas"/> 424 <Caret Line=" 264" Column="1" TopLine="249"/>448 <Caret Line="513" Column="1" TopLine="507"/> 425 449 </Position11> 426 450 <Position12> 427 451 <Filename Value="../UMicroThreading.pas"/> 428 <Caret Line=" 265" Column="1" TopLine="249"/>452 <Caret Line="514" Column="1" TopLine="507"/> 429 453 </Position12> 430 454 <Position13> 431 455 <Filename Value="../UMicroThreading.pas"/> 432 <Caret Line=" 266" Column="1" TopLine="249"/>456 <Caret Line="327" Column="3" TopLine="323"/> 433 457 </Position13> 434 458 <Position14> 435 459 <Filename Value="../UMicroThreading.pas"/> 436 <Caret Line=" 268" Column="1" TopLine="249"/>460 <Caret Line="513" Column="1" TopLine="500"/> 437 461 </Position14> 438 462 <Position15> 439 463 <Filename Value="../UMicroThreading.pas"/> 440 <Caret Line=" 269" Column="1" TopLine="249"/>464 <Caret Line="514" Column="1" TopLine="500"/> 441 465 </Position15> 442 466 <Position16> 443 467 <Filename Value="../UMicroThreading.pas"/> 444 <Caret Line=" 270" Column="1" TopLine="249"/>468 <Caret Line="516" Column="1" TopLine="500"/> 445 469 </Position16> 446 470 <Position17> 447 471 <Filename Value="../UMicroThreading.pas"/> 448 <Caret Line=" 271" Column="1" TopLine="249"/>472 <Caret Line="517" Column="1" TopLine="500"/> 449 473 </Position17> 450 474 <Position18> 451 475 <Filename Value="../UMicroThreading.pas"/> 452 <Caret Line=" 272" Column="1" TopLine="250"/>476 <Caret Line="328" Column="1" TopLine="315"/> 453 477 </Position18> 454 478 <Position19> 455 479 <Filename Value="../UMicroThreading.pas"/> 456 <Caret Line=" 273" Column="1" TopLine="251"/>480 <Caret Line="330" Column="1" TopLine="315"/> 457 481 </Position19> 458 482 <Position20> 459 483 <Filename Value="../UMicroThreading.pas"/> 460 <Caret Line=" 274" Column="1" TopLine="252"/>484 <Caret Line="331" Column="1" TopLine="315"/> 461 485 </Position20> 462 486 <Position21> 463 487 <Filename Value="../UMicroThreading.pas"/> 464 <Caret Line="3 97" Column="1" TopLine="384"/>488 <Caret Line="332" Column="1" TopLine="315"/> 465 489 </Position21> 466 490 <Position22> 467 <Filename Value=" ../UMicroThreading.pas"/>468 <Caret Line=" 400" Column="44" TopLine="384"/>491 <Filename Value="UMainForm.pas"/> 492 <Caret Line="95" Column="17" TopLine="87"/> 469 493 </Position22> 470 494 <Position23> 471 <Filename Value=" ../UMicroThreading.pas"/>472 <Caret Line=" 397" Column="1" TopLine="384"/>495 <Filename Value="UMainForm.pas"/> 496 <Caret Line="235" Column="19" TopLine="224"/> 473 497 </Position23> 474 498 <Position24> 475 499 <Filename Value="../UMicroThreading.pas"/> 476 <Caret Line=" 398" Column="1" TopLine="384"/>500 <Caret Line="513" Column="1" TopLine="500"/> 477 501 </Position24> 478 502 <Position25> 479 <Filename Value=" ../UMicroThreading.pas"/>480 <Caret Line=" 399" Column="1" TopLine="384"/>503 <Filename Value="UMainForm.pas"/> 504 <Caret Line="244" Column="9" TopLine="224"/> 481 505 </Position25> 482 506 <Position26> 483 <Filename Value="../ UMicroThreading.pas"/>484 <Caret Line="400" Column="1 8" TopLine="384"/>507 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32object.inc"/> 508 <Caret Line="400" Column="1" TopLine="387"/> 485 509 </Position26> 486 510 <Position27> 487 511 <Filename Value="../UMicroThreading.pas"/> 488 <Caret Line=" 398" Column="1" TopLine="384"/>512 <Caret Line="517" Column="1" TopLine="500"/> 489 513 </Position27> 490 514 <Position28> 491 <Filename Value=" ../UMicroThreading.pas"/>492 <Caret Line=" 399" Column="1" TopLine="384"/>515 <Filename Value="UMainForm.pas"/> 516 <Caret Line="95" Column="1" TopLine="82"/> 493 517 </Position28> 494 518 <Position29> 495 519 <Filename Value="../UMicroThreading.pas"/> 496 <Caret Line=" 400" Column="1" TopLine="384"/>520 <Caret Line="517" Column="1" TopLine="500"/> 497 521 </Position29> 498 522 <Position30> 499 <Filename Value="../ UMicroThreading.pas"/>500 <Caret Line=" 274" Column="15" TopLine="261"/>523 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32object.inc"/> 524 <Caret Line="394" Column="30" TopLine="387"/> 501 525 </Position30> 502 526 </JumpHistory> … … 534 558 <Item3> 535 559 <Source Value="umainform.pas"/> 536 <Line Value="6 2"/>560 <Line Value="65"/> 537 561 </Item3> 538 562 <Item4> -
MicroThreading/Demo/UMainForm.lfm
r146 r147 1 1 object Form1: TForm1 2 Left = 23 12 Left = 235 3 3 Height = 510 4 Top = 4 84 Top = 44 5 5 Width = 798 6 6 Caption = 'MicroThreading demo' … … 68 68 object Memo1: TMemo 69 69 Left = 10 70 Height = 37971 Top = 12870 Height = 267 71 Top = 240 72 72 Width = 294 73 73 Anchors = [akTop, akLeft, akBottom] … … 78 78 Left = 224 79 79 Height = 25 80 Top = 9680 Top = 208 81 81 Width = 75 82 82 Caption = 'Button2' … … 87 87 Left = 10 88 88 Height = 25 89 Top = 9689 Top = 208 90 90 Width = 75 91 91 Caption = 'Coroutine' … … 96 96 Left = 10 97 97 Height = 14 98 Top = 8098 Top = 192 99 99 Width = 32 100 100 Caption = 'Label2' … … 102 102 end 103 103 object Button4: TButton 104 Left = 1 20104 Left = 10 105 105 Height = 25 106 Top = 12106 Top = 48 107 107 Width = 88 108 108 Caption = 'Start workers' … … 111 111 end 112 112 object SpinEdit1: TSpinEdit 113 Left = 21 7113 Left = 216 114 114 Height = 21 115 Top = 13115 Top = 48 116 116 Width = 82 117 117 MaxValue = 100000 118 118 MinValue = 1 119 119 TabOrder = 6 120 Value = 20 120 Value = 200 121 121 end 122 122 object Button5: TButton 123 123 Left = 168 124 124 Height = 25 125 Top = 48125 Top = 160 126 126 Width = 131 127 127 Caption = 'Get max TThread count' … … 132 132 Left = 88 133 133 Height = 25 134 Top = 48134 Top = 160 135 135 Width = 75 136 136 Caption = 'Button6' 137 137 OnClick = Button6Click 138 138 TabOrder = 8 139 end 140 object SpinEdit2: TSpinEdit 141 Left = 216 142 Height = 21 143 Top = 13 144 Width = 82 145 TabOrder = 9 146 Value = 1 147 end 148 object Label3: TLabel 149 Left = 120 150 Height = 14 151 Top = 20 152 Width = 69 153 Caption = 'Thread count:' 154 ParentColor = False 155 end 156 object Label4: TLabel 157 Left = 104 158 Height = 14 159 Top = 48 160 Width = 92 161 Caption = 'Microthread count:' 162 ParentColor = False 139 163 end 140 164 object Timer1: TTimer -
MicroThreading/Demo/UMainForm.pas
r146 r147 28 28 Label1: TLabel; 29 29 Label2: TLabel; 30 Label3: TLabel; 31 Label4: TLabel; 30 32 ListView1: TListView; 31 33 Memo1: TMemo; 32 34 SpinEdit1: TSpinEdit; 35 SpinEdit2: TSpinEdit; 33 36 Timer1: TTimer; 34 37 procedure Button1Click(Sender: TObject); … … 89 92 Button1.Caption := 'Stop scheduler'; 90 93 Memo1.Clear; 94 Scheduler.ThreadPoolSize := SpinEdit2.Value; 91 95 Scheduler.Start; 92 96 end else begin 93 97 Button1.Caption := 'Start scheduler'; 94 98 Scheduler.Stop; 99 Scheduler.ThreadPoolSize := 0; 95 100 end; 96 101 end; … … 227 232 var 228 233 I: Integer; 234 Q: Integer; 229 235 const 230 236 TotalSteps = 100; … … 233 239 Memo1.Lines.Add('Worker ' + IntToStr(Id)); 234 240 for I := 0 to TotalSteps - 1 do begin 235 Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 236 FloatToStr(ExecutionTime)); 241 Q := 0; 242 while Q < 1000000 do Inc(Q); 243 //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 244 // FloatToStr(ExecutionTime)); 237 245 Completion := I / TotalSteps; 238 246 //Sleep(1 * Id * OneMillisecond);
Note:
See TracChangeset
for help on using the changeset viewer.