Changeset 164
- Timestamp:
- Feb 8, 2011, 11:05:30 AM (14 years ago)
- Location:
- MicroThreading
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r162 r164 43 43 </Item3> 44 44 </RequiredPackages> 45 <Units Count=" 28">45 <Units Count="30"> 46 46 <Unit0> 47 47 <Filename Value="Demo.lpr"/> … … 59 59 <ResourceBaseClass Value="Form"/> 60 60 <UnitName Value="UMainForm"/> 61 <EditorIndex Value="6"/> 62 <WindowIndex Value="0"/> 63 <TopLine Value="372"/> 64 <CursorPos X="21" Y="378"/> 61 <IsVisibleTab Value="True"/> 62 <EditorIndex Value="9"/> 63 <WindowIndex Value="0"/> 64 <TopLine Value="332"/> 65 <CursorPos X="23" Y="342"/> 65 66 <UsageCount Value="270"/> 66 67 <Loaded Value="True"/> … … 70 71 <Filename Value="../UMicroThreading.pas"/> 71 72 <UnitName Value="UMicroThreading"/> 72 <IsVisibleTab Value="True"/>73 73 <EditorIndex Value="0"/> 74 74 <WindowIndex Value="0"/> 75 <TopLine Value="9 76"/>76 <CursorPos X="1 8" Y="986"/>75 <TopLine Value="986"/> 76 <CursorPos X="19" Y="1000"/> 77 77 <UsageCount Value="136"/> 78 78 <Loaded Value="True"/> … … 126 126 <Filename Value="../UPlatform.pas"/> 127 127 <UnitName Value="UPlatform"/> 128 <WindowIndex Value="0"/> 129 <TopLine Value="23"/> 130 <CursorPos X="31" Y="38"/> 128 <EditorIndex Value="3"/> 129 <WindowIndex Value="0"/> 130 <TopLine Value="25"/> 131 <CursorPos X="41" Y="39"/> 131 132 <UsageCount Value="37"/> 133 <Loaded Value="True"/> 132 134 </Unit9> 133 135 <Unit10> … … 136 138 <ResourceBaseClass Value="Form"/> 137 139 <UnitName Value="UMicroThreadList"/> 138 <EditorIndex Value=" 4"/>139 <WindowIndex Value="0"/> 140 <TopLine Value=" 83"/>141 <CursorPos X=" 84" Y="94"/>140 <EditorIndex Value="7"/> 141 <WindowIndex Value="0"/> 142 <TopLine Value="53"/> 143 <CursorPos X="61" Y="61"/> 142 144 <UsageCount Value="23"/> 143 145 <Loaded Value="True"/> … … 239 241 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/packages/fcl-base/src/syncobjs.pp"/> 240 242 <UnitName Value="syncobjs"/> 241 <EditorIndex Value=" 5"/>243 <EditorIndex Value="8"/> 242 244 <WindowIndex Value="0"/> 243 245 <TopLine Value="35"/> … … 248 250 <Unit25> 249 251 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/customlistview.inc"/> 250 <EditorIndex Value=" 1"/>252 <EditorIndex Value="4"/> 251 253 <WindowIndex Value="0"/> 252 254 <TopLine Value="548"/> … … 257 259 <Unit26> 258 260 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/listitem.inc"/> 259 <EditorIndex Value=" 2"/>261 <EditorIndex Value="5"/> 260 262 <WindowIndex Value="0"/> 261 263 <TopLine Value="798"/> … … 266 268 <Unit27> 267 269 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/listitems.inc"/> 268 <EditorIndex Value=" 3"/>270 <EditorIndex Value="6"/> 269 271 <WindowIndex Value="0"/> 270 272 <TopLine Value="65"/> … … 273 275 <Loaded Value="True"/> 274 276 </Unit27> 277 <Unit28> 278 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/forms.pp"/> 279 <UnitName Value="Forms"/> 280 <EditorIndex Value="1"/> 281 <WindowIndex Value="0"/> 282 <TopLine Value="1398"/> 283 <CursorPos X="15" Y="1309"/> 284 <UsageCount Value="10"/> 285 <Loaded Value="True"/> 286 </Unit28> 287 <Unit29> 288 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/application.inc"/> 289 <EditorIndex Value="2"/> 290 <WindowIndex Value="0"/> 291 <TopLine Value="2161"/> 292 <CursorPos X="33" Y="2161"/> 293 <UsageCount Value="10"/> 294 <Loaded Value="True"/> 295 </Unit29> 275 296 </Units> 276 297 <JumpHistory Count="30" HistoryIndex="29"> 277 298 <Position1> 278 <Filename Value=" ../UMicroThreading.pas"/>279 <Caret Line="37 1" Column="16" TopLine="350"/>299 <Filename Value="UMainForm.pas"/> 300 <Caret Line="374" Column="21" TopLine="368"/> 280 301 </Position1> 281 302 <Position2> 282 <Filename Value=" ../UMicroThreading.pas"/>283 <Caret Line=" 652" Column="38" TopLine="631"/>303 <Filename Value="UMainForm.pas"/> 304 <Caret Line="373" Column="21" TopLine="367"/> 284 305 </Position2> 285 306 <Position3> 286 <Filename Value=" ../UMicroThreading.pas"/>287 <Caret Line=" 746" Column="12" TopLine="725"/>307 <Filename Value="UMainForm.pas"/> 308 <Caret Line="372" Column="21" TopLine="366"/> 288 309 </Position3> 289 310 <Position4> 290 <Filename Value="../UMicroThread ing.pas"/>291 <Caret Line=" 750" Column="31" TopLine="729"/>311 <Filename Value="../UMicroThreadList.pas"/> 312 <Caret Line="94" Column="84" TopLine="83"/> 292 313 </Position4> 293 314 <Position5> 294 <Filename Value="../UMicroThread ing.pas"/>295 <Caret Line=" 753" Column="26" TopLine="732"/>315 <Filename Value="../UMicroThreadList.pas"/> 316 <Caret Line="17" Column="7" TopLine="4"/> 296 317 </Position5> 297 318 <Position6> 298 <Filename Value="../UMicroThread ing.pas"/>299 <Caret Line=" 935" Column="13" TopLine="914"/>319 <Filename Value="../UMicroThreadList.pas"/> 320 <Caret Line="15" Column="38" TopLine="7"/> 300 321 </Position6> 301 322 <Position7> 302 <Filename Value="../UMicroThread ing.pas"/>303 <Caret Line=" 983" Column="31" TopLine="968"/>323 <Filename Value="../UMicroThreadList.pas"/> 324 <Caret Line="17" Column="12" TopLine="4"/> 304 325 </Position7> 305 326 <Position8> 306 <Filename Value="../UMicroThread ing.pas"/>307 <Caret Line="1 013" Column="24" TopLine="992"/>327 <Filename Value="../UMicroThreadList.pas"/> 328 <Caret Line="18" Column="12" TopLine="4"/> 308 329 </Position8> 309 330 <Position9> 310 <Filename Value="../UMicroThread ing.pas"/>311 <Caret Line=" 8" Column="19" TopLine="1"/>331 <Filename Value="../UMicroThreadList.pas"/> 332 <Caret Line="19" Column="12" TopLine="4"/> 312 333 </Position9> 313 334 <Position10> 314 <Filename Value="../UMicroThread ing.pas"/>315 <Caret Line=" 652" Column="51" TopLine="639"/>335 <Filename Value="../UMicroThreadList.pas"/> 336 <Caret Line="20" Column="12" TopLine="4"/> 316 337 </Position10> 317 338 <Position11> 318 <Filename Value="../UMicroThread ing.pas"/>319 <Caret Line=" 645" Column="28" TopLine="639"/>339 <Filename Value="../UMicroThreadList.pas"/> 340 <Caret Line="21" Column="12" TopLine="4"/> 320 341 </Position11> 321 342 <Position12> 322 <Filename Value="../UMicroThread ing.pas"/>323 <Caret Line=" 653" Column="43" TopLine="639"/>343 <Filename Value="../UMicroThreadList.pas"/> 344 <Caret Line="22" Column="12" TopLine="4"/> 324 345 </Position12> 325 346 <Position13> 326 <Filename Value=" ../UMicroThreading.pas"/>327 <Caret Line=" 479" Column="1" TopLine="466"/>347 <Filename Value="UMainForm.pas"/> 348 <Caret Line="372" Column="21" TopLine="26"/> 328 349 </Position13> 329 350 <Position14> 330 <Filename Value="../UMicroThread ing.pas"/>331 <Caret Line=" 712" Column="1" TopLine="699"/>351 <Filename Value="../UMicroThreadList.pas"/> 352 <Caret Line="23" Column="12" TopLine="13"/> 332 353 </Position14> 333 354 <Position15> 334 <Filename Value="../UMicroThread ing.pas"/>335 <Caret Line=" 582" Column="18" TopLine="571"/>355 <Filename Value="../UMicroThreadList.pas"/> 356 <Caret Line="68" Column="3" TopLine="53"/> 336 357 </Position15> 337 358 <Position16> 338 <Filename Value="../UMicroThread ing.pas"/>339 <Caret Line=" 583" Column="65" TopLine="571"/>359 <Filename Value="../UMicroThreadList.pas"/> 360 <Caret Line="69" Column="1" TopLine="53"/> 340 361 </Position16> 341 362 <Position17> 342 <Filename Value=" ../UMicroThreading.pas"/>343 <Caret Line=" 582" Column="20" TopLine="571"/>363 <Filename Value="UMainForm.pas"/> 364 <Caret Line="85" Column="15" TopLine="69"/> 344 365 </Position17> 345 366 <Position18> 346 <Filename Value="../UMicroThread ing.pas"/>347 <Caret Line=" 583" Column="1" TopLine="571"/>367 <Filename Value="../UMicroThreadList.pas"/> 368 <Caret Line="9" Column="43" TopLine="1"/> 348 369 </Position18> 349 370 <Position19> 350 <Filename Value="../UMicroThread ing.pas"/>351 <Caret Line="7 11" Column="1" TopLine="698"/>371 <Filename Value="../UMicroThreadList.pas"/> 372 <Caret Line="72" Column="1" TopLine="53"/> 352 373 </Position19> 353 374 <Position20> 354 375 <Filename Value="../UMicroThreading.pas"/> 355 <Caret Line=" 712" Column="1" TopLine="698"/>376 <Caret Line="1006" Column="18" TopLine="991"/> 356 377 </Position20> 357 378 <Position21> 358 379 <Filename Value="../UMicroThreading.pas"/> 359 <Caret Line=" 713" Column="1" TopLine="698"/>380 <Caret Line="1010" Column="26" TopLine="991"/> 360 381 </Position21> 361 382 <Position22> 362 383 <Filename Value="../UMicroThreading.pas"/> 363 <Caret Line=" 714" Column="1" TopLine="698"/>384 <Caret Line="1009" Column="22" TopLine="991"/> 364 385 </Position22> 365 386 <Position23> 366 387 <Filename Value="../UMicroThreading.pas"/> 367 <Caret Line=" 715" Column="1" TopLine="698"/>388 <Caret Line="1004" Column="43" TopLine="991"/> 368 389 </Position23> 369 390 <Position24> 370 <Filename Value=" ../UMicroThreadList.pas"/>371 <Caret Line=" 95" Column="54" TopLine="83"/>391 <Filename Value="UMainForm.pas"/> 392 <Caret Line="337" Column="23" TopLine="327"/> 372 393 </Position24> 373 394 <Position25> 374 <Filename Value=" ../UMicroThreading.pas"/>375 <Caret Line=" 240" Column="45" TopLine="227"/>395 <Filename Value="UMainForm.pas"/> 396 <Caret Line="338" Column="23" TopLine="328"/> 376 397 </Position25> 377 398 <Position26> 378 <Filename Value=" ../UMicroThreading.pas"/>379 <Caret Line=" 984" Column="40" TopLine="979"/>399 <Filename Value="UMainForm.pas"/> 400 <Caret Line="339" Column="23" TopLine="329"/> 380 401 </Position26> 381 402 <Position27> 382 <Filename Value=" ../UMicroThreading.pas"/>383 <Caret Line=" 992" Column="38" TopLine="979"/>403 <Filename Value="UMainForm.pas"/> 404 <Caret Line="338" Column="23" TopLine="328"/> 384 405 </Position27> 385 406 <Position28> 386 <Filename Value=" ../UMicroThreading.pas"/>387 <Caret Line=" 989" Column="55" TopLine="976"/>407 <Filename Value="UMainForm.pas"/> 408 <Caret Line="339" Column="23" TopLine="329"/> 388 409 </Position28> 389 410 <Position29> 390 <Filename Value=" ../UMicroThreading.pas"/>391 <Caret Line=" 990" Column="24" TopLine="976"/>411 <Filename Value="UMainForm.pas"/> 412 <Caret Line="340" Column="23" TopLine="330"/> 392 413 </Position29> 393 414 <Position30> 394 <Filename Value=" ../UMicroThreading.pas"/>395 <Caret Line=" 989" Column="29" TopLine="976"/>415 <Filename Value="UMainForm.pas"/> 416 <Caret Line="341" Column="23" TopLine="331"/> 396 417 </Position30> 397 418 </JumpHistory> -
MicroThreading/Demo/UMainForm.lfm
r162 r164 5 5 Width = 816 6 6 Caption = 'MicroThreading demo' 7 ClientHeight = 5 337 ClientHeight = 514 8 8 ClientWidth = 816 9 Menu = MainMenu1 9 10 OnCreate = FormCreate 10 11 OnDestroy = FormDestroy … … 13 14 object PageControl1: TPageControl 14 15 Left = 8 15 Height = 5 1916 Height = 500 16 17 Top = 8 17 18 Width = 802 … … 22 23 object TabSheet2: TTabSheet 23 24 Caption = 'Scheduler state' 24 ClientHeight = 4 9325 ClientHeight = 474 25 26 ClientWidth = 794 26 27 object GroupBox1: TGroupBox … … 33 34 ClientWidth = 201 34 35 TabOrder = 0 35 object Label5: TLabel36 Left = 937 Height = 1438 Top = 439 Width = 11740 Caption = 'Logical processor count:'41 ParentColor = False42 end43 object Label6: TLabel44 Left = 15045 Height = 1446 Top = 447 Width = 1348 Caption = ' '49 ParentColor = False50 end51 object Label7: TLabel52 Left = 853 Height = 1454 Top = 2055 Width = 6956 Caption = 'Thread count:'57 ParentColor = False58 end59 object Label8: TLabel60 Left = 961 Height = 1462 Top = 3663 Width = 9564 Caption = 'Micro thread count:'65 ParentColor = False66 end67 object Label9: TLabel68 Left = 15069 Height = 1470 Top = 2071 Width = 1372 Caption = ' '73 ParentColor = False74 end75 object Label10: TLabel76 Left = 15177 Height = 1478 Top = 3679 Width = 1380 Caption = ' '81 ParentColor = False82 end83 36 object Label15: TLabel 84 37 Left = 9 … … 403 356 top = 115 404 357 end 358 object MainMenu1: TMainMenu 359 left = 512 360 top = 115 361 object MenuItem1: TMenuItem 362 Caption = 'New Item1' 363 object MenuItem2: TMenuItem 364 Caption = 'New Item2' 365 end 366 object MenuItem4: TMenuItem 367 Caption = 'New Item4' 368 end 369 end 370 object MenuItem3: TMenuItem 371 Caption = 'New Item3' 372 end 373 end 405 374 end -
MicroThreading/Demo/UMainForm.pas
r162 r164 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ExtCtrls, Spin, UMicroThreading, DateUtils, UPlatform,9 ComCtrls, ExtCtrls, Spin, Menus, UMicroThreading, DateUtils, UPlatform, 10 10 UMicroThreadList, UThreadEx; 11 11 … … 46 46 GroupBox2: TGroupBox; 47 47 GroupBox3: TGroupBox; 48 Label10: TLabel;49 48 Label11: TLabel; 50 49 Label12: TLabel; … … 57 56 Label3: TLabel; 58 57 Label4: TLabel; 59 Label5: TLabel; 60 Label6: TLabel; 61 Label7: TLabel; 62 Label8: TLabel; 63 Label9: TLabel; 58 MainMenu1: TMainMenu; 64 59 Memo1: TMemo; 60 MenuItem1: TMenuItem; 61 MenuItem2: TMenuItem; 62 MenuItem3: TMenuItem; 63 MenuItem4: TMenuItem; 65 64 PageControl1: TPageControl; 66 65 SpinEdit1: TSpinEdit; … … 134 133 DoubleBuffered := True; 135 134 // ListView1.DoubleBuffered := True; 136 Label6.Caption := IntToStr(GetLogicalProcessorCount);137 135 Event := TMicroThreadEvent.Create; 138 136 MicroThreadList := TMicroThreadList.Create(Self); … … 345 343 Label2.Caption := DateTimeToStr(NowPrecise) + ' ' + 346 344 FloatToStr(Frac(NowPrecise / OneSecond)); 347 Label9.Caption := IntToStr(MainScheduler.ThreadPoolCount);348 Label10.Caption := IntToStr(MainScheduler.MicroThreadCount);349 345 end; 350 346 -
MicroThreading/UMicroThreadList.lfm
r162 r164 1 1 object MicroThreadListForm: TMicroThreadListForm 2 Left = 3672 Left = 476 3 3 Height = 423 4 Top = 11 84 Top = 111 5 5 Width = 569 6 6 Caption = 'Microthread list' 7 7 ClientHeight = 423 8 8 ClientWidth = 569 9 OnClose = FormClose 9 10 OnHide = FormHide 10 11 OnShow = FormShow 11 12 LCLVersion = '0.9.31' 12 object Panel1: TPanel 13 Left = 0 14 Height = 248 15 Top = 0 16 Width = 569 17 Align = alTop 18 BevelOuter = bvNone 19 ClientHeight = 248 20 ClientWidth = 569 13 object PageControl1: TPageControl 14 Left = 8 15 Height = 409 16 Top = 7 17 Width = 553 18 ActivePage = TabSheet1 19 Anchors = [akTop, akLeft, akRight, akBottom] 20 TabIndex = 0 21 21 TabOrder = 0 22 object Label1: TLabel 23 Left = 8 24 Height = 14 25 Top = 8 26 Width = 67 27 Caption = 'Microthreads:' 28 ParentColor = False 22 object TabSheet1: TTabSheet 23 Caption = 'State' 24 ClientHeight = 383 25 ClientWidth = 545 26 object Label5: TLabel 27 Left = 9 28 Height = 14 29 Top = 11 30 Width = 117 31 Caption = 'Logical processor count:' 32 ParentColor = False 33 end 34 object Label7: TLabel 35 Left = 8 36 Height = 14 37 Top = 27 38 Width = 69 39 Caption = 'Thread count:' 40 ParentColor = False 41 end 42 object Label8: TLabel 43 Left = 9 44 Height = 14 45 Top = 43 46 Width = 95 47 Caption = 'Micro thread count:' 48 ParentColor = False 49 end 50 object Label10: TLabel 51 Left = 151 52 Height = 14 53 Top = 43 54 Width = 13 55 Caption = ' ' 56 ParentColor = False 57 end 58 object Label9: TLabel 59 Left = 150 60 Height = 14 61 Top = 27 62 Width = 13 63 Caption = ' ' 64 ParentColor = False 65 end 66 object Label6: TLabel 67 Left = 150 68 Height = 14 69 Top = 11 70 Width = 13 71 Caption = ' ' 72 ParentColor = False 73 end 74 object Label1: TLabel 75 Left = 8 76 Height = 14 77 Top = 63 78 Width = 128 79 Caption = 'Main thread loop duration:' 80 ParentColor = False 81 end 82 object Label2: TLabel 83 Left = 148 84 Height = 14 85 Top = 64 86 Width = 13 87 Caption = ' ' 88 ParentColor = False 89 end 29 90 end 30 object ListView1: TListView 31 Left = 8 32 Height = 218 33 Top = 24 34 Width = 557 35 Anchors = [akTop, akLeft, akRight, akBottom] 36 Columns = < 37 item 38 Caption = 'Id' 39 Width = 40 40 end 41 item 42 Caption = 'Usage' 43 end 44 item 45 Caption = 'Priority' 46 Width = 40 47 end 48 item 49 Caption = 'State' 50 Width = 60 51 end 52 item 53 Caption = 'Block state' 54 end 55 item 56 Caption = 'Execution time' 57 Width = 70 58 end 59 item 60 Caption = 'Tick count' 61 end 62 item 63 Caption = 'Completion' 64 end 65 item 66 Caption = 'Used stack' 67 end 68 item 69 Caption = 'Name' 70 Width = 70 71 end> 72 OwnerData = True 73 ReadOnly = True 74 RowSelect = True 75 TabOrder = 0 76 ViewStyle = vsReport 77 OnData = ListView1Data 91 object TabSheet2: TTabSheet 92 Caption = 'Threads' 93 ClientHeight = 383 94 ClientWidth = 545 95 object ListView2: TListView 96 Left = 4 97 Height = 376 98 Top = 3 99 Width = 536 100 Anchors = [akTop, akLeft, akRight, akBottom] 101 Columns = < 102 item 103 Caption = 'Id' 104 end 105 item 106 Caption = 'State' 107 Width = 100 108 end 109 item 110 Caption = 'Microthread Id' 111 Width = 70 112 end 113 item 114 Caption = 'Loop duration' 115 Width = 70 116 end> 117 OwnerData = True 118 ReadOnly = True 119 RowSelect = True 120 TabOrder = 0 121 ViewStyle = vsReport 122 OnData = ListView2Data 123 end 78 124 end 79 end 80 object Panel2: TPanel 81 Left = 0 82 Height = 170 83 Top = 253 84 Width = 569 85 Align = alClient 86 BevelOuter = bvNone 87 ClientHeight = 170 88 ClientWidth = 569 89 TabOrder = 1 90 object ListView2: TListView 91 Left = 8 92 Height = 142 93 Top = 19 94 Width = 557 95 Anchors = [akTop, akLeft, akRight, akBottom] 96 Columns = < 97 item 98 Caption = 'Id' 99 end 100 item 101 Caption = 'State' 102 Width = 100 103 end 104 item 105 Caption = 'Microthread Id' 106 Width = 70 107 end 108 item 109 Caption = 'Loop duration' 110 Width = 70 111 end> 112 OwnerData = True 113 ReadOnly = True 114 RowSelect = True 115 TabOrder = 0 116 ViewStyle = vsReport 117 OnData = ListView2Data 125 object TabSheet3: TTabSheet 126 Caption = 'Microthreads' 127 ClientHeight = 383 128 ClientWidth = 545 129 object ListView1: TListView 130 Left = 4 131 Height = 376 132 Top = 3 133 Width = 537 134 Anchors = [akTop, akLeft, akRight, akBottom] 135 Columns = < 136 item 137 Caption = 'Id' 138 Width = 40 139 end 140 item 141 Caption = 'Usage' 142 end 143 item 144 Caption = 'Priority' 145 Width = 40 146 end 147 item 148 Caption = 'State' 149 Width = 60 150 end 151 item 152 Caption = 'Block state' 153 end 154 item 155 Caption = 'Execution time' 156 Width = 70 157 end 158 item 159 Caption = 'Tick count' 160 end 161 item 162 Caption = 'Completion' 163 end 164 item 165 Caption = 'Used stack' 166 end 167 item 168 Caption = 'Name' 169 Width = 70 170 end> 171 OwnerData = True 172 ReadOnly = True 173 RowSelect = True 174 TabOrder = 0 175 ViewStyle = vsReport 176 OnData = ListView1Data 177 end 118 178 end 119 object Label2: TLabel120 Left = 8121 Height = 14122 Top = 3123 Width = 44124 Caption = 'Threads:'125 ParentColor = False126 end127 end128 object Splitter1: TSplitter129 Cursor = crVSplit130 Left = 0131 Height = 5132 Top = 248133 Width = 569134 Align = alTop135 ResizeAnchor = akTop136 179 end 137 180 object TimerRedraw: TTimer 138 181 Enabled = False 139 Interval = 50182 Interval = 200 140 183 OnTimer = TimerRedrawTimer 141 184 left = 192 -
MicroThreading/UMicroThreadList.pas
r162 r164 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 ExtCtrls, StdCtrls, DateUtils ;9 ExtCtrls, StdCtrls, DateUtils, UPlatform; 10 10 11 11 type … … 14 14 15 15 TMicroThreadListForm = class(TForm) 16 published 17 Label10: TLabel; 18 Label5: TLabel; 19 Label6: TLabel; 20 Label7: TLabel; 21 Label8: TLabel; 22 Label9: TLabel; 23 TimerRedraw: TTimer; 16 24 Label1: TLabel; 17 25 Label2: TLabel; 18 26 ListView1: TListView; 19 27 ListView2: TListView; 20 Panel1: TPanel; 21 Panel2: TPanel; 22 Splitter1: TSplitter; 23 TimerRedraw: TTimer; 28 PageControl1: TPageControl; 29 TabSheet1: TTabSheet; 30 TabSheet2: TTabSheet; 31 TabSheet3: TTabSheet; 32 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 24 33 procedure FormHide(Sender: TObject); 25 34 procedure FormShow(Sender: TObject); … … 57 66 ListView2.Items[-1]; 58 67 ListView2.Refresh; 68 69 Label6.Caption := IntToStr(GetLogicalProcessorCount); 70 Label9.Caption := IntToStr(MainScheduler.ThreadPoolCount); 71 Label10.Caption := IntToStr(MainScheduler.MicroThreadCount); 72 Label2.Caption := FloatToStr(MainScheduler.MainThreadOutsideDuration / OneMillisecond) + ' ms'; 59 73 end; 60 74 … … 120 134 end; 121 135 136 procedure TMicroThreadListForm.FormClose(Sender: TObject; 137 var CloseAction: TCloseAction); 138 begin 139 TimerRedraw.Enabled := False; 140 end; 141 122 142 123 143 end. -
MicroThreading/UMicroThreading.pas
r162 r164 24 24 25 25 const 26 DefaultStackSize = $ 4000;26 DefaultStackSize = $8000; 27 27 28 28 resourcestring … … 210 210 FMainThreadStarter: TTimer; 211 211 FEvents: TObjectList; 212 FMainThreadOutsideStart: TDateTime; 213 FMainThreadOutsideDuration: TDateTime; 212 214 function GetMicroThreadCount: Integer; 213 215 function GetThreadPoolCount: Integer; … … 241 243 property Active: Boolean read FActive write SetActive; 242 244 property UseMainThread: Boolean read FUseMainThread write SetUseMainThread; 245 property MainThreadOutsideDuration: TDateTime read FMainThreadOutsideDuration; 243 246 end; 244 247 … … 339 342 MT := GetCurrentMicroThread; 340 343 if Assigned(MT) then Result := MT.WaitForEvent(Event, Duration) 341 else raise Exception.Create(SNotInThread); 344 else begin 345 while not Event.Signaled do begin 346 Sleep(1); 347 Application.ProcessMessages; 348 end; 349 //raise Exception.Create(SNotInThread); 342 350 // else Result := Event.WaitFor(Trunc(Duration / OneMillisecond)); 351 end; 343 352 end; 344 353 … … 487 496 function TMicroThreadManager.Execute(Count: Integer): Integer; 488 497 begin 489 FLoopStart := NowPrecise;498 //FLoopStart := NowPrecise; 490 499 FStack := StackBottom; 491 500 FStackSize := StackBottom + StackLength; … … 494 503 Yield; 495 504 Result := FExecutedCount; 496 FLoopDuration := NowPrecise - FLoopStart;505 //FLoopDuration := NowPrecise - FLoopStart; 497 506 end; 498 507 … … 615 624 begin 616 625 if Assigned(FThread) then 617 FThread.Synchronize(FThread, AMethod); 626 FThread.Synchronize(FThread, AMethod) 627 else AMethod; 618 628 end; 619 629 … … 744 754 procedure TMicroThread.WaitFor; 745 755 begin 746 if GetMicroThreadId <> -1 then 747 while not ((FState = tsBlocked) and (FBlockState = tbsTerminated)) do begin 748 MTSleep(1); 756 if GetMicroThreadId <> -1 then begin 757 // Called from another microthread 758 while not ((FState = tsBlocked) and (FBlockState = tbsTerminated)) do begin 759 MTSleep(1); 760 end; 761 end else begin 762 // Called directly from main thread 763 while not ((FState = tsBlocked) and (FBlockState = tbsTerminated)) do begin 764 Sleep(1); 765 Application.ProcessMessages; 766 end; 749 767 end; 750 768 end; … … 762 780 try 763 781 Event.FMicroThreadsLock.Acquire; 782 if Event.Signaled then begin 783 Result := wrSignaled; 784 Exit; 785 end; 764 786 Event.FMicroThreads.Add(Self); 765 787 FBlockTime := NowPrecise + Duration; … … 890 912 FMainThreadManager.FScheduler := Self; 891 913 UseMainThread := False; 892 BurstCount := 100;914 BurstCount := 50; 893 915 end; 894 916 … … 984 1006 begin 985 1007 // try 986 Duration := 100 * OneMillisecond; 987 StartTime := NowPrecise; 1008 FMainThreadOutsideDuration := NowPrecise - FMainThreadOutsideStart; 1009 BurstCount := 1; 1010 Duration := 50 * OneMillisecond; 1011 StartTime := Now; 988 1012 Executed := -1; 989 while (Executed <> 0) and ((Now Precise- StartTime) < Duration) do begin1013 while (Executed <> 0) and ((Now - StartTime) < Duration) do begin 990 1014 Executed := FMainThreadManager.Execute(BurstCount); 991 1015 end; … … 999 1023 // raise; 1000 1024 // end; 1025 FMainThreadOutsideStart := NowPrecise; 1001 1026 end; 1002 1027 -
MicroThreading/UPlatform.pas
r156 r164 28 28 {$IFDEF Windows}TimerValue: Int64;{$ENDIF} 29 29 begin 30 try 31 NowPreciseLock.Acquire; 30 // Result := Now; 31 //try 32 //NowPreciseLock.Acquire; 32 33 {$IFDEF Windows} 33 34 QueryPerformanceCounter(TimerValue); … … 42 43 {$ENDIF} 43 44 44 Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond; 45 finally 46 NowPreciseLock.Release; 47 end; 45 Result := Result * OneSecond; 46 //Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond; 47 //finally 48 //NowPreciseLock.Release; 49 //end; 48 50 end; 49 51
Note:
See TracChangeset
for help on using the changeset viewer.