Changeset 168 for MicroThreading
- Timestamp:
- Feb 10, 2011, 4:10:59 PM (14 years ago)
- Location:
- MicroThreading
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r166 r168 43 43 </Item3> 44 44 </RequiredPackages> 45 <Units Count="3 0">45 <Units Count="34"> 46 46 <Unit0> 47 47 <Filename Value="Demo.lpr"/> … … 59 59 <ResourceBaseClass Value="Form"/> 60 60 <UnitName Value="UMainForm"/> 61 <EditorIndex Value=" 9"/>61 <EditorIndex Value="13"/> 62 62 <WindowIndex Value="0"/> 63 63 <TopLine Value="393"/> … … 73 73 <EditorIndex Value="0"/> 74 74 <WindowIndex Value="0"/> 75 <TopLine Value=" 914"/>76 <CursorPos X="1 1" Y="928"/>75 <TopLine Value="885"/> 76 <CursorPos X="1" Y="897"/> 77 77 <UsageCount Value="136"/> 78 78 <Loaded Value="True"/> … … 84 84 <TopLine Value="1"/> 85 85 <CursorPos X="27" Y="9"/> 86 <UsageCount Value="1 9"/>86 <UsageCount Value="18"/> 87 87 </Unit3> 88 88 <Unit4> … … 92 92 <TopLine Value="1"/> 93 93 <CursorPos X="12" Y="8"/> 94 <UsageCount Value="2 6"/>94 <UsageCount Value="25"/> 95 95 </Unit4> 96 96 <Unit5> … … 100 100 <TopLine Value="1034"/> 101 101 <CursorPos X="14" Y="1037"/> 102 <UsageCount Value="2 1"/>102 <UsageCount Value="20"/> 103 103 </Unit5> 104 104 <Unit6> … … 107 107 <TopLine Value="1638"/> 108 108 <CursorPos X="28" Y="1645"/> 109 <UsageCount Value=" 2"/>109 <UsageCount Value="1"/> 110 110 </Unit6> 111 111 <Unit7> … … 114 114 <TopLine Value="147"/> 115 115 <CursorPos X="1" Y="158"/> 116 <UsageCount Value="2 2"/>116 <UsageCount Value="21"/> 117 117 </Unit7> 118 118 <Unit8> … … 121 121 <TopLine Value="14"/> 122 122 <CursorPos X="11" Y="27"/> 123 <UsageCount Value="2 3"/>123 <UsageCount Value="22"/> 124 124 </Unit8> 125 125 <Unit9> … … 130 130 <TopLine Value="25"/> 131 131 <CursorPos X="41" Y="39"/> 132 <UsageCount Value=" 38"/>132 <UsageCount Value="42"/> 133 133 <Loaded Value="True"/> 134 134 </Unit9> … … 140 140 <EditorIndex Value="7"/> 141 141 <WindowIndex Value="0"/> 142 <TopLine Value=" 53"/>143 <CursorPos X=" 61" Y="61"/>144 <UsageCount Value="2 4"/>142 <TopLine Value="121"/> 143 <CursorPos X="10" Y="138"/> 144 <UsageCount Value="28"/> 145 145 <Loaded Value="True"/> 146 146 <LoadedDesigner Value="True"/> … … 151 151 <TopLine Value="191"/> 152 152 <CursorPos X="13" Y="204"/> 153 <UsageCount Value="2 1"/>153 <UsageCount Value="20"/> 154 154 </Unit11> 155 155 <Unit12> … … 158 158 <TopLine Value="600"/> 159 159 <CursorPos X="1" Y="613"/> 160 <UsageCount Value=" 20"/>160 <UsageCount Value="19"/> 161 161 </Unit12> 162 162 <Unit13> … … 165 165 <TopLine Value="1483"/> 166 166 <CursorPos X="51" Y="1490"/> 167 <UsageCount Value=" 20"/>167 <UsageCount Value="19"/> 168 168 </Unit13> 169 169 <Unit14> … … 172 172 <TopLine Value="30"/> 173 173 <CursorPos X="3" Y="15"/> 174 <UsageCount Value=" 20"/>174 <UsageCount Value="19"/> 175 175 </Unit14> 176 176 <Unit15> … … 180 180 <TopLine Value="1"/> 181 181 <CursorPos X="20" Y="1"/> 182 <UsageCount Value=" 30"/>182 <UsageCount Value="29"/> 183 183 </Unit15> 184 184 <Unit16> … … 187 187 <TopLine Value="469"/> 188 188 <CursorPos X="18" Y="484"/> 189 <UsageCount Value=" 20"/>189 <UsageCount Value="19"/> 190 190 </Unit16> 191 191 <Unit17> … … 194 194 <TopLine Value="920"/> 195 195 <CursorPos X="17" Y="942"/> 196 <UsageCount Value=" 20"/>196 <UsageCount Value="19"/> 197 197 </Unit17> 198 198 <Unit18> … … 201 201 <TopLine Value="14"/> 202 202 <CursorPos X="11" Y="27"/> 203 <UsageCount Value=" 20"/>203 <UsageCount Value="19"/> 204 204 </Unit18> 205 205 <Unit19> … … 208 208 <TopLine Value="57"/> 209 209 <CursorPos X="5" Y="70"/> 210 <UsageCount Value=" 20"/>210 <UsageCount Value="19"/> 211 211 </Unit19> 212 212 <Unit20> … … 215 215 <TopLine Value="169"/> 216 216 <CursorPos X="33" Y="184"/> 217 <UsageCount Value=" 20"/>217 <UsageCount Value="19"/> 218 218 </Unit20> 219 219 <Unit21> … … 222 222 <TopLine Value="429"/> 223 223 <CursorPos X="19" Y="435"/> 224 <UsageCount Value="1 9"/>224 <UsageCount Value="18"/> 225 225 </Unit21> 226 226 <Unit22> … … 229 229 <TopLine Value="329"/> 230 230 <CursorPos X="14" Y="342"/> 231 <UsageCount Value="1 9"/>231 <UsageCount Value="18"/> 232 232 </Unit22> 233 233 <Unit23> … … 236 236 <TopLine Value="29"/> 237 237 <CursorPos X="23" Y="42"/> 238 <UsageCount Value="1 6"/>238 <UsageCount Value="15"/> 239 239 </Unit23> 240 240 <Unit24> 241 241 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/packages/fcl-base/src/syncobjs.pp"/> 242 242 <UnitName Value="syncobjs"/> 243 <EditorIndex Value=" 8"/>243 <EditorIndex Value="12"/> 244 244 <WindowIndex Value="0"/> 245 245 <TopLine Value="35"/> 246 246 <CursorPos X="18" Y="45"/> 247 <UsageCount Value="1 3"/>247 <UsageCount Value="17"/> 248 248 <Loaded Value="True"/> 249 249 </Unit24> … … 254 254 <TopLine Value="548"/> 255 255 <CursorPos X="1" Y="561"/> 256 <UsageCount Value="1 2"/>256 <UsageCount Value="16"/> 257 257 <Loaded Value="True"/> 258 258 </Unit25> … … 263 263 <TopLine Value="798"/> 264 264 <CursorPos X="1" Y="821"/> 265 <UsageCount Value="1 2"/>265 <UsageCount Value="16"/> 266 266 <Loaded Value="True"/> 267 267 </Unit26> … … 272 272 <TopLine Value="65"/> 273 273 <CursorPos X="29" Y="75"/> 274 <UsageCount Value="1 2"/>274 <UsageCount Value="16"/> 275 275 <Loaded Value="True"/> 276 276 </Unit27> … … 282 282 <TopLine Value="1398"/> 283 283 <CursorPos X="15" Y="1309"/> 284 <UsageCount Value="1 1"/>284 <UsageCount Value="15"/> 285 285 <Loaded Value="True"/> 286 286 </Unit28> … … 291 291 <TopLine Value="2161"/> 292 292 <CursorPos X="33" Y="2161"/> 293 <UsageCount Value="15"/> 294 <Loaded Value="True"/> 295 </Unit29> 296 <Unit30> 297 <Filename Value="../UMicroThreadCallStack.pas"/> 298 <ComponentName Value="CallStackForm"/> 299 <ResourceBaseClass Value="Form"/> 300 <UnitName Value="UMicroThreadCallStack"/> 301 <EditorIndex Value="8"/> 302 <WindowIndex Value="0"/> 303 <TopLine Value="44"/> 304 <CursorPos X="22" Y="66"/> 305 <UsageCount Value="14"/> 306 <Loaded Value="True"/> 307 <LoadedDesigner Value="True"/> 308 </Unit30> 309 <Unit31> 310 <Filename Value="../UStackTrace.pas"/> 311 <UnitName Value="UStackTrace"/> 312 <EditorIndex Value="9"/> 313 <WindowIndex Value="0"/> 314 <TopLine Value="17"/> 315 <CursorPos X="26" Y="122"/> 293 316 <UsageCount Value="11"/> 294 317 <Loaded Value="True"/> 295 </Unit29> 318 </Unit31> 319 <Unit32> 320 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/rtl/inc/systemh.inc"/> 321 <EditorIndex Value="10"/> 322 <WindowIndex Value="0"/> 323 <TopLine Value="974"/> 324 <CursorPos X="10" Y="987"/> 325 <UsageCount Value="11"/> 326 <Loaded Value="True"/> 327 </Unit32> 328 <Unit33> 329 <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/rtl/i386/i386.inc"/> 330 <EditorIndex Value="11"/> 331 <WindowIndex Value="0"/> 332 <TopLine Value="1135"/> 333 <CursorPos X="10" Y="1139"/> 334 <UsageCount Value="11"/> 335 <Loaded Value="True"/> 336 </Unit33> 296 337 </Units> 297 338 <JumpHistory Count="30" HistoryIndex="29"> 298 339 <Position1> 299 <Filename Value="../U MicroThreading.pas"/>300 <Caret Line=" 939" Column="1" TopLine="932"/>340 <Filename Value="../UStackTrace.pas"/> 341 <Caret Line="76" Column="60" TopLine="63"/> 301 342 </Position1> 302 343 <Position2> 303 <Filename Value="../U MicroThreading.pas"/>304 <Caret Line=" 940" Column="1" TopLine="932"/>344 <Filename Value="../UStackTrace.pas"/> 345 <Caret Line="74" Column="17" TopLine="63"/> 305 346 </Position2> 306 347 <Position3> 307 <Filename Value="../U MicroThreading.pas"/>308 <Caret Line=" 941" Column="1" TopLine="932"/>348 <Filename Value="../UStackTrace.pas"/> 349 <Caret Line="63" Column="27" TopLine="49"/> 309 350 </Position3> 310 351 <Position4> 311 <Filename Value="../U MicroThreading.pas"/>312 <Caret Line=" 942" Column="1" TopLine="932"/>352 <Filename Value="../UStackTrace.pas"/> 353 <Caret Line="79" Column="32" TopLine="64"/> 313 354 </Position4> 314 355 <Position5> 315 <Filename Value="../U MicroThreading.pas"/>316 <Caret Line=" 944" Column="1" TopLine="932"/>356 <Filename Value="../UStackTrace.pas"/> 357 <Caret Line="76" Column="66" TopLine="61"/> 317 358 </Position5> 318 359 <Position6> 319 <Filename Value="../U MicroThreading.pas"/>320 <Caret Line=" 946" Column="1" TopLine="932"/>360 <Filename Value="../UStackTrace.pas"/> 361 <Caret Line="74" Column="1" TopLine="61"/> 321 362 </Position6> 322 363 <Position7> 323 <Filename Value="../U MicroThreading.pas"/>324 <Caret Line=" 937" Column="1" TopLine="932"/>364 <Filename Value="../UStackTrace.pas"/> 365 <Caret Line="75" Column="1" TopLine="61"/> 325 366 </Position7> 326 367 <Position8> 327 <Filename Value="../U MicroThreading.pas"/>328 <Caret Line=" 938" Column="1" TopLine="932"/>368 <Filename Value="../UStackTrace.pas"/> 369 <Caret Line="76" Column="1" TopLine="61"/> 329 370 </Position8> 330 371 <Position9> 331 <Filename Value="../U MicroThreading.pas"/>332 <Caret Line=" 846" Column="1" TopLine="833"/>372 <Filename Value="../UStackTrace.pas"/> 373 <Caret Line="74" Column="1" TopLine="61"/> 333 374 </Position9> 334 375 <Position10> 335 <Filename Value="../U MicroThreading.pas"/>336 <Caret Line=" 859" Column="1" TopLine="837"/>376 <Filename Value="../UStackTrace.pas"/> 377 <Caret Line="75" Column="1" TopLine="61"/> 337 378 </Position10> 338 379 <Position11> 339 380 <Filename Value="../UMicroThreading.pas"/> 340 <Caret Line="8 47" Column="1" TopLine="837"/>381 <Caret Line="854" Column="3" TopLine="847"/> 341 382 </Position11> 342 383 <Position12> 343 384 <Filename Value="../UMicroThreading.pas"/> 344 <Caret Line="8 48" Column="1" TopLine="837"/>385 <Caret Line="853" Column="41" TopLine="847"/> 345 386 </Position12> 346 387 <Position13> 347 388 <Filename Value="../UMicroThreading.pas"/> 348 <Caret Line="8 49" Column="1" TopLine="837"/>389 <Caret Line="854" Column="1" TopLine="847"/> 349 390 </Position13> 350 391 <Position14> 351 392 <Filename Value="../UMicroThreading.pas"/> 352 <Caret Line="85 0" Column="1" TopLine="837"/>393 <Caret Line="855" Column="1" TopLine="847"/> 353 394 </Position14> 354 395 <Position15> 355 <Filename Value="../U MicroThreading.pas"/>356 <Caret Line=" 851" Column="1" TopLine="837"/>396 <Filename Value="../UStackTrace.pas"/> 397 <Caret Line="74" Column="1" TopLine="61"/> 357 398 </Position15> 358 399 <Position16> 359 <Filename Value="../U MicroThreading.pas"/>360 <Caret Line=" 852" Column="1" TopLine="837"/>400 <Filename Value="../UStackTrace.pas"/> 401 <Caret Line="75" Column="1" TopLine="61"/> 361 402 </Position16> 362 403 <Position17> 363 <Filename Value="../U MicroThreading.pas"/>364 <Caret Line=" 853" Column="1" TopLine="837"/>404 <Filename Value="../UStackTrace.pas"/> 405 <Caret Line="76" Column="1" TopLine="61"/> 365 406 </Position17> 366 407 <Position18> 367 <Filename Value="../U MicroThreading.pas"/>368 <Caret Line=" 854" Column="1" TopLine="837"/>408 <Filename Value="../UStackTrace.pas"/> 409 <Caret Line="74" Column="1" TopLine="61"/> 369 410 </Position18> 370 411 <Position19> 371 <Filename Value="../U MicroThreading.pas"/>372 <Caret Line=" 857" Column="1" TopLine="837"/>412 <Filename Value="../UStackTrace.pas"/> 413 <Caret Line="75" Column="50" TopLine="61"/> 373 414 </Position19> 374 415 <Position20> 375 <Filename Value="../U MicroThreading.pas"/>376 <Caret Line=" 858" Column="1" TopLine="837"/>416 <Filename Value="../UStackTrace.pas"/> 417 <Caret Line="74" Column="45" TopLine="61"/> 377 418 </Position20> 378 419 <Position21> 379 <Filename Value="../U MicroThreading.pas"/>380 <Caret Line=" 859" Column="1" TopLine="837"/>420 <Filename Value="../UStackTrace.pas"/> 421 <Caret Line="73" Column="29" TopLine="61"/> 381 422 </Position21> 382 423 <Position22> 383 <Filename Value="../U MicroThreading.pas"/>384 <Caret Line=" 939" Column="1" TopLine="926"/>424 <Filename Value="../UStackTrace.pas"/> 425 <Caret Line="76" Column="1" TopLine="61"/> 385 426 </Position22> 386 427 <Position23> 387 <Filename Value="../U MicroThreading.pas"/>388 <Caret Line="9 40" Column="1" TopLine="926"/>428 <Filename Value="../UStackTrace.pas"/> 429 <Caret Line="91" Column="1" TopLine="78"/> 389 430 </Position23> 390 431 <Position24> 391 <Filename Value="../UMicroThread ing.pas"/>392 <Caret Line=" 941" Column="1" TopLine="926"/>432 <Filename Value="../UMicroThreadCallStack.pas"/> 433 <Caret Line="67" Column="38" TopLine="46"/> 393 434 </Position24> 394 435 <Position25> 395 <Filename Value="../U MicroThreading.pas"/>396 <Caret Line=" 942" Column="1" TopLine="926"/>436 <Filename Value="../UStackTrace.pas"/> 437 <Caret Line="76" Column="1" TopLine="63"/> 397 438 </Position25> 398 439 <Position26> 399 <Filename Value="../U MicroThreading.pas"/>400 <Caret Line=" 938" Column="45" TopLine="926"/>440 <Filename Value="../UStackTrace.pas"/> 441 <Caret Line="78" Column="1" TopLine="63"/> 401 442 </Position26> 402 443 <Position27> 403 <Filename Value="../UMicroThread ing.pas"/>404 <Caret Line=" 940" Column="1" TopLine="914"/>444 <Filename Value="../UMicroThreadCallStack.pas"/> 445 <Caret Line="66" Column="19" TopLine="47"/> 405 446 </Position27> 406 447 <Position28> 407 <Filename Value="../UMicroThread ing.pas"/>408 <Caret Line=" 901" Column="32" TopLine="888"/>448 <Filename Value="../UMicroThreadCallStack.pas"/> 449 <Caret Line="67" Column="14" TopLine="47"/> 409 450 </Position28> 410 451 <Position29> 411 <Filename Value="../UMicroThread ing.pas"/>412 <Caret Line=" 236" Column="43" TopLine="236"/>452 <Filename Value="../UMicroThreadCallStack.pas"/> 453 <Caret Line="66" Column="22" TopLine="44"/> 413 454 </Position29> 414 455 <Position30> 415 <Filename Value="../UMicroThread ing.pas"/>416 <Caret Line=" 926" Column="22" TopLine="913"/>456 <Filename Value="../UMicroThreadList.pas"/> 457 <Caret Line="138" Column="10" TopLine="121"/> 417 458 </Position30> 418 459 </JumpHistory> -
MicroThreading/Demo/UMainForm.lfm
r166 r168 1 1 object MainForm: TMainForm 2 Left = 2822 Left = 0 3 3 Height = 533 4 Top = 945 Width = 8164 Top = 13 5 Width = 792 6 6 Caption = 'MicroThreading demo' 7 7 ClientHeight = 514 8 ClientWidth = 8168 ClientWidth = 792 9 9 Menu = MainMenu1 10 10 OnCreate = FormCreate … … 16 16 Height = 500 17 17 Top = 8 18 Width = 80218 Width = 778 19 19 ActivePage = TabSheet1 20 20 Anchors = [akTop, akLeft, akRight, akBottom] … … 108 108 Caption = 'Job control' 109 109 ClientHeight = 474 110 ClientWidth = 7 94110 ClientWidth = 770 111 111 object ButtonAddWorkers: TButton 112 112 Left = 10 -
MicroThreading/MicroThreading.lpk
r162 r168 16 16 <Description Value="Micro threading subsystem. "/> 17 17 <License Value="GNU/GPL"/> 18 <Version Minor=" 1"/>19 <Files Count=" 5">18 <Version Minor="2"/> 19 <Files Count="6"> 20 20 <Item1> 21 21 <Filename Value="UMicroThreading.pas"/> … … 39 39 <UnitName Value="UThreadEx"/> 40 40 </Item5> 41 <Item6> 42 <Filename Value="UMicroThreadCallStack.pas"/> 43 <UnitName Value="UMicroThreadCallStack"/> 44 </Item6> 41 45 </Files> 42 46 <Type Value="RunAndDesignTime"/> 43 47 <RequiredPkgs Count="4"> 44 48 <Item1> 45 <PackageName Value=" LCLBase"/>49 <PackageName Value="ExceptionLogger"/> 46 50 </Item1> 47 51 <Item2> -
MicroThreading/MicroThreading.pas
r160 r168 8 8 9 9 uses 10 UMicroThreading, UPlatform, UMicroThreadList, UThreadEx, LazarusPackageIntf; 10 UMicroThreading, UPlatform, UMicroThreadList, UThreadEx, 11 UMicroThreadCallStack, LazarusPackageIntf; 11 12 12 13 implementation -
MicroThreading/UMicroThreadList.lfm
r164 r168 1 1 object MicroThreadListForm: TMicroThreadListForm 2 Left = 4762 Left = 321 3 3 Height = 423 4 Top = 1 114 Top = 108 5 5 Width = 569 6 6 Caption = 'Microthread list' … … 8 8 ClientWidth = 569 9 9 OnClose = FormClose 10 OnCreate = FormCreate 11 OnDestroy = FormDestroy 10 12 OnHide = FormHide 11 13 OnShow = FormShow … … 16 18 Top = 7 17 19 Width = 553 18 ActivePage = TabSheet 120 ActivePage = TabSheet3 19 21 Anchors = [akTop, akLeft, akRight, akBottom] 20 TabIndex = 022 TabIndex = 2 21 23 TabOrder = 0 22 24 object TabSheet1: TTabSheet … … 170 172 end> 171 173 OwnerData = True 174 PopupMenu = PopupMenu1 172 175 ReadOnly = True 173 176 RowSelect = True … … 185 188 top = 85 186 189 end 190 object PopupMenu1: TPopupMenu 191 left = 192 192 top = 136 193 object MenuItemCallStack: TMenuItem 194 Caption = 'Call stack' 195 OnClick = MenuItemCallStackClick 196 end 197 end 187 198 end -
MicroThreading/UMicroThreadList.pas
r164 r168 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls, 9 ExtCtrls, StdCtrls, DateUtils, UPlatform;9 ExtCtrls, StdCtrls, Menus, DateUtils, UPlatform, UMicroThreadCallStack; 10 10 11 11 type … … 21 21 Label8: TLabel; 22 22 Label9: TLabel; 23 MenuItemCallStack: TMenuItem; 24 PopupMenu1: TPopupMenu; 23 25 TimerRedraw: TTimer; 24 26 Label1: TLabel; … … 31 33 TabSheet3: TTabSheet; 32 34 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 35 procedure FormCreate(Sender: TObject); 36 procedure FormDestroy(Sender: TObject); 33 37 procedure FormHide(Sender: TObject); 34 38 procedure FormShow(Sender: TObject); 35 39 procedure ListView1Data(Sender: TObject; Item: TListItem); 36 40 procedure ListView2Data(Sender: TObject; Item: TListItem); 41 procedure MenuItemCallStackClick(Sender: TObject); 37 42 procedure TimerRedrawTimer(Sender: TObject); 38 43 private 39 { private declarations }44 CallStackForm: TCallStackForm; 40 45 public 41 46 { public declarations } … … 81 86 with TMicroThread(MainScheduler.MicroThreads[Item.Index]) do begin 82 87 Item.Caption := IntToStr(Id); 88 Item.Data := TMicroThread(MainScheduler.MicroThreads[Item.Index]); 83 89 Item.SubItems.Add(''); 84 90 Item.SubItems.Add(IntToStr(Priority)); … … 124 130 end; 125 131 132 procedure TMicroThreadListForm.MenuItemCallStackClick(Sender: TObject); 133 begin 134 if Assigned(ListView1.Selected) then 135 with TMicroThread(ListView1.Selected.Data) do begin 136 //Suspend; 137 CallStackForm.Show(BasePointer); 138 //Resume; 139 end; 140 end; 141 126 142 procedure TMicroThreadListForm.FormShow(Sender: TObject); 127 143 begin … … 140 156 end; 141 157 158 procedure TMicroThreadListForm.FormCreate(Sender: TObject); 159 begin 160 CallStackForm := TCallStackForm.Create(nil); 161 end; 162 163 procedure TMicroThreadListForm.FormDestroy(Sender: TObject); 164 begin 165 CallStackForm.Free; 166 end; 167 142 168 143 169 end. -
MicroThreading/UMicroThreading.pas
r166 r168 141 141 property Manager: TMicroThreadManager read FManager write SetManager; 142 142 property StackUsed: Integer read GetStackUsed; 143 property BasePointer: Pointer read FBasePointer; 143 144 end; 144 145 … … 391 392 Dec(FCounter); 392 393 if FMicroThreads.Count > 0 then begin 393 // Release one waiting micro thread and lower counter394 // Release one waiting micro thread 394 395 TMicroThread(FMicroThreads[0]).FState := tsWaiting; 395 396 FMicroThreads.Delete(0); … … 435 436 Form := TMicroThreadListForm.Create(Self); 436 437 end; 437 438 439 438 440 439 { TMicroThreadMethod } … … 797 796 begin 798 797 try 798 FScheduler.FMicroThreadsLock.Acquire; 799 799 CriticalSection.Lock.Acquire; 800 800 Inc(CriticalSection.FCounter); … … 805 805 try 806 806 CriticalSection.Lock.Release; 807 FScheduler.FMicroThreadsLock.Release; 807 808 Yield; 808 809 finally 810 FScheduler.FMicroThreadsLock.Acquire; 809 811 CriticalSection.Lock.Acquire; 810 812 end; … … 812 814 finally 813 815 CriticalSection.Lock.Release; 816 FScheduler.FMicroThreadsLock.Release; 814 817 end; 815 818 end; … … 845 848 const StackSize: SizeUInt = DefaultStackSize); 846 849 begin 850 // Setup stack 847 851 FStackSize := StackSize; 848 852 FStack := GetMem(FStackSize); 849 FBasePointer := FStack + FStackSize ;853 FBasePointer := FStack + FStackSize - SizeOf(Pointer); 850 854 FStackPointer := FBasePointer - SizeOf(Pointer); 855 FillChar(FStackPointer^, 2 * SizeOf(Pointer), 0); 856 851 857 FExecutionTime := 0; 852 858 FState := tsWaiting; … … 886 892 887 893 procedure TMicroThread.Suspend; 894 var 895 MT: TMicroThread; 888 896 begin 889 897 FStatePending := tsSuspended; 890 //Yield; 898 MT := GetCurrentMicroThread; 899 if Assigned(MT) then Yield; 891 900 end; 892 901 … … 918 927 begin 919 928 try 920 NewMicroThread := TMicroThreadSimple.Create( False);929 NewMicroThread := TMicroThreadSimple.Create(True); 921 930 NewMicroThread.Method := Method; 922 931 NewMicroThread.FScheduler := Self; 923 932 NewMicroThread.FreeOnTerminate := not WaitForFinish; 933 NewMicroThread.Start; 924 934 if WaitForFinish then begin 925 935 CurrentMT := GetCurrentMicroThread; 926 while not ((NewMicroThread.FState = tsBlocked) and 927 (NewMicroThread.FBlockState = tbsTerminated)) do begin 928 try 929 FMicroThreadsLock.Release; 930 if Assigned(CurrentMT) then CurrentMT.MTSleep(1 * OneMillisecond) 931 else begin 932 Sleep(1); 933 Application.ProcessMessages; 936 try 937 FMicroThreadsLock.Acquire; 938 while not ((NewMicroThread.FState = tsBlocked) and 939 (NewMicroThread.FBlockState = tbsTerminated)) do begin 940 try 941 FMicroThreadsLock.Release; 942 if Assigned(CurrentMT) then CurrentMT.MTSleep(1 * OneMillisecond) 943 else begin 944 Sleep(1); 945 Application.ProcessMessages; 946 end; 947 finally 948 FMicroThreadsLock.Acquire; 934 949 end; 935 finally936 FMicroThreadsLock.Acquire;937 950 end; 951 finally 952 FMicroThreadsLock.Release; 938 953 end; 939 954 end;
Note:
See TracChangeset
for help on using the changeset viewer.