Changeset 156
- Timestamp:
- Jan 28, 2011, 2:12:42 PM (14 years ago)
- Location:
- MicroThreading
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/Demo.lpi
r155 r156 39 39 </Item2> 40 40 </RequiredPackages> 41 <Units Count="6 3">41 <Units Count="65"> 42 42 <Unit0> 43 43 <Filename Value="Demo.lpr"/> 44 44 <IsPartOfProject Value="True"/> 45 45 <UnitName Value="Demo"/> 46 <EditorIndex Value="4"/>47 46 <WindowIndex Value="0"/> 48 47 <TopLine Value="1"/> 49 <CursorPos X="21" Y="18"/> 50 <UsageCount Value="70"/> 51 <Loaded Value="True"/> 48 <CursorPos X="34" Y="16"/> 49 <UsageCount Value="82"/> 52 50 </Unit0> 53 51 <Unit1> … … 57 55 <ResourceBaseClass Value="Form"/> 58 56 <UnitName Value="UMainForm"/> 59 <EditorIndex Value=" 0"/>60 <WindowIndex Value="0"/> 61 <TopLine Value="2 06"/>62 <CursorPos X="1" Y="2 11"/>63 <UsageCount Value=" 70"/>57 <EditorIndex Value="9"/> 58 <WindowIndex Value="0"/> 59 <TopLine Value="270"/> 60 <CursorPos X="1" Y="284"/> 61 <UsageCount Value="82"/> 64 62 <Loaded Value="True"/> 65 63 <LoadedDesigner Value="True"/> … … 69 67 <UnitName Value="UMicroThreading"/> 70 68 <IsVisibleTab Value="True"/> 71 <EditorIndex Value=" 2"/>72 <WindowIndex Value="0"/> 73 <TopLine Value=" 708"/>74 <CursorPos X=" 24" Y="718"/>75 <UsageCount Value=" 37"/>69 <EditorIndex Value="0"/> 70 <WindowIndex Value="0"/> 71 <TopLine Value="513"/> 72 <CursorPos X="9" Y="525"/> 73 <UsageCount Value="43"/> 76 74 <Loaded Value="True"/> 77 75 </Unit2> … … 82 80 <TopLine Value="55"/> 83 81 <CursorPos X="3" Y="70"/> 84 <UsageCount Value=" 9"/>82 <UsageCount Value="8"/> 85 83 </Unit3> 86 84 <Unit4> … … 89 87 <TopLine Value="346"/> 90 88 <CursorPos X="24" Y="351"/> 91 <UsageCount Value=" 7"/>89 <UsageCount Value="6"/> 92 90 </Unit4> 93 91 <Unit5> … … 96 94 <TopLine Value="1"/> 97 95 <CursorPos X="1" Y="1"/> 98 <UsageCount Value=" 7"/>96 <UsageCount Value="6"/> 99 97 <DefaultSyntaxHighlighter Value="XML"/> 100 98 </Unit5> … … 105 103 <TopLine Value="286"/> 106 104 <CursorPos X="1" Y="1"/> 107 <UsageCount Value=" 7"/>105 <UsageCount Value="6"/> 108 106 </Unit6> 109 107 <Unit7> … … 113 111 <TopLine Value="1"/> 114 112 <CursorPos X="1" Y="8"/> 115 <UsageCount Value=" 9"/>113 <UsageCount Value="8"/> 116 114 <DefaultSyntaxHighlighter Value="Delphi"/> 117 115 </Unit7> … … 122 120 <TopLine Value="56"/> 123 121 <CursorPos X="24" Y="77"/> 124 <UsageCount Value="1 8"/>122 <UsageCount Value="17"/> 125 123 <DefaultSyntaxHighlighter Value="Delphi"/> 126 124 </Unit8> … … 131 129 <TopLine Value="264"/> 132 130 <CursorPos X="37" Y="141"/> 133 <UsageCount Value="1 8"/>131 <UsageCount Value="17"/> 134 132 <DefaultSyntaxHighlighter Value="Delphi"/> 135 133 </Unit9> … … 140 138 <TopLine Value="302"/> 141 139 <CursorPos X="5" Y="33"/> 142 <UsageCount Value=" 7"/>140 <UsageCount Value="6"/> 143 141 </Unit10> 144 142 <Unit11> … … 147 145 <TopLine Value="479"/> 148 146 <CursorPos X="3" Y="494"/> 149 <UsageCount Value=" 10"/>147 <UsageCount Value="9"/> 150 148 </Unit11> 151 149 <Unit12> … … 154 152 <TopLine Value="1046"/> 155 153 <CursorPos X="34" Y="1053"/> 156 <UsageCount Value="1 6"/>154 <UsageCount Value="15"/> 157 155 </Unit12> 158 156 <Unit13> … … 161 159 <TopLine Value="317"/> 162 160 <CursorPos X="1" Y="341"/> 163 <UsageCount Value=" 9"/>161 <UsageCount Value="8"/> 164 162 </Unit13> 165 163 <Unit14> … … 168 166 <TopLine Value="45"/> 169 167 <CursorPos X="1" Y="62"/> 170 <UsageCount Value=" 9"/>168 <UsageCount Value="8"/> 171 169 </Unit14> 172 170 <Unit15> … … 175 173 <TopLine Value="1670"/> 176 174 <CursorPos X="1" Y="1685"/> 177 <UsageCount Value=" 10"/>175 <UsageCount Value="9"/> 178 176 </Unit15> 179 177 <Unit16> … … 183 181 <TopLine Value="290"/> 184 182 <CursorPos X="36" Y="306"/> 185 <UsageCount Value="1 9"/>183 <UsageCount Value="18"/> 186 184 </Unit16> 187 185 <Unit17> … … 190 188 <TopLine Value="67"/> 191 189 <CursorPos X="10" Y="91"/> 192 <UsageCount Value=" 7"/>190 <UsageCount Value="6"/> 193 191 </Unit17> 194 192 <Unit18> … … 197 195 <TopLine Value="1823"/> 198 196 <CursorPos X="3" Y="1838"/> 199 <UsageCount Value="1 1"/>197 <UsageCount Value="10"/> 200 198 </Unit18> 201 199 <Unit19> … … 204 202 <TopLine Value="1348"/> 205 203 <CursorPos X="1" Y="1363"/> 206 <UsageCount Value=" 9"/>204 <UsageCount Value="8"/> 207 205 </Unit19> 208 206 <Unit20> … … 211 209 <TopLine Value="32"/> 212 210 <CursorPos X="48" Y="50"/> 213 <UsageCount Value=" 8"/>211 <UsageCount Value="7"/> 214 212 </Unit20> 215 213 <Unit21> … … 218 216 <TopLine Value="8"/> 219 217 <CursorPos X="11" Y="25"/> 220 <UsageCount Value=" 10"/>218 <UsageCount Value="9"/> 221 219 </Unit21> 222 220 <Unit22> … … 226 224 <TopLine Value="1"/> 227 225 <CursorPos X="25" Y="9"/> 228 <UsageCount Value="1 1"/>226 <UsageCount Value="10"/> 229 227 </Unit22> 230 228 <Unit23> … … 233 231 <TopLine Value="38"/> 234 232 <CursorPos X="29" Y="50"/> 235 <UsageCount Value="1 5"/>233 <UsageCount Value="14"/> 236 234 </Unit23> 237 235 <Unit24> … … 240 238 <TopLine Value="106"/> 241 239 <CursorPos X="10" Y="119"/> 242 <UsageCount Value="1 8"/>240 <UsageCount Value="17"/> 243 241 </Unit24> 244 242 <Unit25> … … 247 245 <TopLine Value="254"/> 248 246 <CursorPos X="12" Y="258"/> 249 <UsageCount Value="1 1"/>247 <UsageCount Value="10"/> 250 248 </Unit25> 251 249 <Unit26> … … 255 253 <TopLine Value="581"/> 256 254 <CursorPos X="11" Y="585"/> 257 <UsageCount Value="1 1"/>255 <UsageCount Value="10"/> 258 256 </Unit26> 259 257 <Unit27> 260 258 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/win/wininc/redef.inc"/> 261 <WindowIndex Value="0"/> 262 <TopLine Value="525"/> 263 <CursorPos X="11" Y="538"/> 264 <UsageCount Value="11"/> 259 <EditorIndex Value="7"/> 260 <WindowIndex Value="0"/> 261 <TopLine Value="739"/> 262 <CursorPos X="27" Y="752"/> 263 <UsageCount Value="17"/> 264 <Loaded Value="True"/> 265 265 </Unit27> 266 266 <Unit28> 267 267 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/packages/fcl-base/src/syncobjs.pp"/> 268 268 <UnitName Value="syncobjs"/> 269 <WindowIndex Value="0"/> 270 <TopLine Value="57"/> 271 <CursorPos X="16" Y="70"/> 272 <UsageCount Value="12"/> 269 <EditorIndex Value="2"/> 270 <WindowIndex Value="0"/> 271 <TopLine Value="104"/> 272 <CursorPos X="28" Y="106"/> 273 <UsageCount Value="14"/> 274 <Loaded Value="True"/> 273 275 </Unit28> 274 276 <Unit29> 275 277 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/inc/threadh.inc"/> 276 <WindowIndex Value="0"/> 277 <TopLine Value="18"/> 278 <CursorPos X="50" Y="31"/> 279 <UsageCount Value="12"/> 278 <EditorIndex Value="3"/> 279 <WindowIndex Value="0"/> 280 <TopLine Value="138"/> 281 <CursorPos X="11" Y="151"/> 282 <UsageCount Value="14"/> 283 <Loaded Value="True"/> 280 284 </Unit29> 281 285 <Unit30> 282 286 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/inc/thread.inc"/> 283 <WindowIndex Value="0"/> 284 <TopLine Value="109"/> 285 <CursorPos X="3" Y="112"/> 286 <UsageCount Value="12"/> 287 <EditorIndex Value="4"/> 288 <WindowIndex Value="0"/> 289 <TopLine Value="199"/> 290 <CursorPos X="3" Y="202"/> 291 <UsageCount Value="14"/> 292 <Loaded Value="True"/> 287 293 </Unit30> 288 294 <Unit31> 289 295 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/win/sysosh.inc"/> 290 <WindowIndex Value="0"/> 291 <TopLine Value="12"/> 292 <CursorPos X="3" Y="25"/> 293 <UsageCount Value="12"/> 296 <EditorIndex Value="12"/> 297 <WindowIndex Value="0"/> 298 <TopLine Value="8"/> 299 <CursorPos X="3" Y="33"/> 300 <UsageCount Value="14"/> 301 <Loaded Value="True"/> 294 302 </Unit31> 295 303 <Unit32> 296 304 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/> 297 <EditorIndex Value=" 8"/>298 <WindowIndex Value="0"/> 299 <TopLine Value=" 1467"/>300 <CursorPos X=" 5" Y="1488"/>301 <UsageCount Value=" 18"/>305 <EditorIndex Value="10"/> 306 <WindowIndex Value="0"/> 307 <TopLine Value="302"/> 308 <CursorPos X="19" Y="319"/> 309 <UsageCount Value="20"/> 302 310 <Loaded Value="True"/> 303 311 </Unit32> 304 312 <Unit33> 305 313 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/win/tthread.inc"/> 306 <EditorIndex Value="9"/>307 314 <WindowIndex Value="0"/> 308 315 <TopLine Value="52"/> 309 316 <CursorPos X="25" Y="65"/> 310 <UsageCount Value="15"/> 311 <Loaded Value="True"/> 317 <UsageCount Value="14"/> 312 318 </Unit33> 313 319 <Unit34> … … 316 322 <TopLine Value="130"/> 317 323 <CursorPos X="10" Y="143"/> 318 <UsageCount Value="1 2"/>324 <UsageCount Value="11"/> 319 325 </Unit34> 320 326 <Unit35> … … 323 329 <TopLine Value="1923"/> 324 330 <CursorPos X="6" Y="1936"/> 325 <UsageCount Value="1 2"/>331 <UsageCount Value="11"/> 326 332 </Unit35> 327 333 <Unit36> 328 334 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classes.inc"/> 329 <EditorIndex Value="10"/>330 335 <WindowIndex Value="0"/> 331 336 <TopLine Value="124"/> 332 337 <CursorPos X="3" Y="126"/> 333 <UsageCount Value="18"/> 334 <Loaded Value="True"/> 338 <UsageCount Value="17"/> 335 339 </Unit36> 336 340 <Unit37> … … 339 343 <TopLine Value="181"/> 340 344 <CursorPos X="21" Y="194"/> 341 <UsageCount Value="1 2"/>345 <UsageCount Value="11"/> 342 346 </Unit37> 343 347 <Unit38> 344 348 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/sysutils/osutilsh.inc"/> 345 <EditorIndex Value="5"/>346 349 <WindowIndex Value="0"/> 347 350 <TopLine Value="14"/> 348 351 <CursorPos X="17" Y="27"/> 349 <UsageCount Value="13"/> 350 <Loaded Value="True"/> 352 <UsageCount Value="12"/> 351 353 </Unit38> 352 354 <Unit39> … … 355 357 <TopLine Value="2275"/> 356 358 <CursorPos X="39" Y="2285"/> 357 <UsageCount Value="1 1"/>359 <UsageCount Value="10"/> 358 360 </Unit39> 359 361 <Unit40> 360 362 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/inc/systemh.inc"/> 361 <EditorIndex Value="3"/>362 363 <WindowIndex Value="0"/> 363 364 <TopLine Value="480"/> 364 365 <CursorPos X="3" Y="493"/> 365 <UsageCount Value="10"/> 366 <Loaded Value="True"/> 366 <UsageCount Value="9"/> 367 367 </Unit40> 368 368 <Unit41> … … 371 371 <TopLine Value="197"/> 372 372 <CursorPos X="30" Y="208"/> 373 <UsageCount Value=" 9"/>373 <UsageCount Value="8"/> 374 374 </Unit41> 375 375 <Unit42> … … 378 378 <TopLine Value="737"/> 379 379 <CursorPos X="21" Y="747"/> 380 <UsageCount Value=" 9"/>380 <UsageCount Value="8"/> 381 381 </Unit42> 382 382 <Unit43> … … 385 385 <TopLine Value="96"/> 386 386 <CursorPos X="1" Y="1"/> 387 <UsageCount Value=" 9"/>387 <UsageCount Value="8"/> 388 388 </Unit43> 389 389 <Unit44> … … 392 392 <TopLine Value="221"/> 393 393 <CursorPos X="1" Y="235"/> 394 <UsageCount Value="1 2"/>394 <UsageCount Value="11"/> 395 395 </Unit44> 396 396 <Unit45> 397 397 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32object.inc"/> 398 <EditorIndex Value="1"/> 398 399 <WindowIndex Value="0"/> 399 400 <TopLine Value="387"/> 400 401 <CursorPos X="1" Y="400"/> 401 <UsageCount Value="12"/> 402 <UsageCount Value="11"/> 403 <Loaded Value="True"/> 402 404 </Unit45> 403 405 <Unit46> … … 406 408 <TopLine Value="6081"/> 407 409 <CursorPos X="6" Y="6094"/> 408 <UsageCount Value="1 2"/>410 <UsageCount Value="11"/> 409 411 </Unit46> 410 412 <Unit47> … … 413 415 <TopLine Value="160"/> 414 416 <CursorPos X="12" Y="163"/> 415 <UsageCount Value=" 9"/>417 <UsageCount Value="8"/> 416 418 </Unit47> 417 419 <Unit48> 418 420 <Filename Value="../UPlatform.pas"/> 419 421 <UnitName Value="UPlatform"/> 420 <EditorIndex Value=" 12"/>421 <WindowIndex Value="0"/> 422 <TopLine Value=" 19"/>423 <CursorPos X=" 1" Y="41"/>424 <UsageCount Value=" 17"/>422 <EditorIndex Value="6"/> 423 <WindowIndex Value="0"/> 424 <TopLine Value="23"/> 425 <CursorPos X="31" Y="38"/> 426 <UsageCount Value="23"/> 425 427 <Loaded Value="True"/> 426 428 </Unit48> … … 430 432 <TopLine Value="9153"/> 431 433 <CursorPos X="8" Y="9166"/> 432 <UsageCount Value=" 9"/>434 <UsageCount Value="8"/> 433 435 </Unit49> 434 436 <Unit50> … … 438 440 <TopLine Value="1"/> 439 441 <CursorPos X="1" Y="1"/> 440 <UsageCount Value=" 9"/>442 <UsageCount Value="8"/> 441 443 </Unit50> 442 444 <Unit51> … … 445 447 <TopLine Value="2380"/> 446 448 <CursorPos X="30" Y="2390"/> 447 <UsageCount Value=" 9"/>449 <UsageCount Value="8"/> 448 450 </Unit51> 449 451 <Unit52> … … 452 454 <TopLine Value="150"/> 453 455 <CursorPos X="55" Y="162"/> 454 <UsageCount Value=" 9"/>456 <UsageCount Value="8"/> 455 457 </Unit52> 456 458 <Unit53> … … 459 461 <TopLine Value="5227"/> 460 462 <CursorPos X="1" Y="5242"/> 461 <UsageCount Value=" 9"/>463 <UsageCount Value="8"/> 462 464 </Unit53> 463 465 <Unit54> … … 467 469 <TopLine Value="102"/> 468 470 <CursorPos X="1" Y="121"/> 469 <UsageCount Value=" 9"/>471 <UsageCount Value="8"/> 470 472 </Unit54> 471 473 <Unit55> … … 474 476 <TopLine Value="3515"/> 475 477 <CursorPos X="1" Y="3531"/> 476 <UsageCount Value=" 9"/>478 <UsageCount Value="8"/> 477 479 </Unit55> 478 480 <Unit56> … … 481 483 <TopLine Value="1159"/> 482 484 <CursorPos X="1" Y="1174"/> 483 <UsageCount Value=" 9"/>485 <UsageCount Value="8"/> 484 486 </Unit56> 485 487 <Unit57> … … 487 489 <EditorIndex Value="11"/> 488 490 <WindowIndex Value="0"/> 489 <TopLine Value=" 590"/>490 <CursorPos X=" 14" Y="594"/>491 <UsageCount Value="1 3"/>491 <TopLine Value="909"/> 492 <CursorPos X="26" Y="917"/> 493 <UsageCount Value="15"/> 492 494 <Loaded Value="True"/> 493 495 </Unit57> 494 496 <Unit58> 495 497 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32callback.inc"/> 496 <EditorIndex Value="7"/>497 498 <WindowIndex Value="0"/> 498 499 <TopLine Value="1086"/> 499 500 <CursorPos X="1" Y="1099"/> 500 <UsageCount Value="13"/> 501 <Loaded Value="True"/> 501 <UsageCount Value="12"/> 502 502 </Unit58> 503 503 <Unit59> … … 507 507 <TopLine Value="357"/> 508 508 <CursorPos X="3" Y="370"/> 509 <UsageCount Value="1 1"/>509 <UsageCount Value="10"/> 510 510 </Unit59> 511 511 <Unit60> 512 512 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/customtimer.pas"/> 513 513 <UnitName Value="CustomTimer"/> 514 <EditorIndex Value="6"/>515 514 <WindowIndex Value="0"/> 516 515 <TopLine Value="40"/> 517 516 <CursorPos X="17" Y="53"/> 518 <UsageCount Value="12"/> 519 <Loaded Value="True"/> 517 <UsageCount Value="11"/> 520 518 </Unit60> 521 519 <Unit61> 522 520 <Filename Value="../ReadMe.txt"/> 523 <EditorIndex Value="13"/>524 521 <WindowIndex Value="0"/> 525 522 <TopLine Value="1"/> 526 523 <CursorPos X="17" Y="14"/> 527 <UsageCount Value="10"/> 528 <Loaded Value="True"/> 524 <UsageCount Value="9"/> 529 525 <DefaultSyntaxHighlighter Value="None"/> 530 526 </Unit61> … … 532 528 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/forms.pp"/> 533 529 <UnitName Value="Forms"/> 534 <EditorIndex Value="1"/>535 530 <WindowIndex Value="0"/> 536 531 <TopLine Value="57"/> 537 532 <CursorPos X="3" Y="70"/> 538 <UsageCount Value="10"/> 539 <Loaded Value="True"/> 533 <UsageCount Value="9"/> 540 534 </Unit62> 535 <Unit63> 536 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/sysutils/sysutilh.inc"/> 537 <EditorIndex Value="8"/> 538 <WindowIndex Value="0"/> 539 <TopLine Value="1"/> 540 <CursorPos X="55" Y="4"/> 541 <UsageCount Value="16"/> 542 <Loaded Value="True"/> 543 </Unit63> 544 <Unit64> 545 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/controls.pp"/> 546 <UnitName Value="Controls"/> 547 <EditorIndex Value="5"/> 548 <WindowIndex Value="0"/> 549 <TopLine Value="2660"/> 550 <CursorPos X="1" Y="2673"/> 551 <UsageCount Value="15"/> 552 <Loaded Value="True"/> 553 </Unit64> 541 554 </Units> 542 <JumpHistory Count="30" HistoryIndex="2 9">555 <JumpHistory Count="30" HistoryIndex="28"> 543 556 <Position1> 544 557 <Filename Value="../UMicroThreading.pas"/> 545 <Caret Line="7 18" Column="1" TopLine="701"/>558 <Caret Line="773" Column="1" TopLine="760"/> 546 559 </Position1> 547 560 <Position2> 548 561 <Filename Value="../UMicroThreading.pas"/> 549 <Caret Line="7 19" Column="1" TopLine="701"/>562 <Caret Line="774" Column="1" TopLine="760"/> 550 563 </Position2> 551 564 <Position3> 552 565 <Filename Value="../UMicroThreading.pas"/> 553 <Caret Line="7 20" Column="1" TopLine="701"/>566 <Caret Line="772" Column="1" TopLine="760"/> 554 567 </Position3> 555 568 <Position4> 556 569 <Filename Value="../UMicroThreading.pas"/> 557 <Caret Line="7 18" Column="1" TopLine="701"/>570 <Caret Line="773" Column="1" TopLine="760"/> 558 571 </Position4> 559 572 <Position5> 560 573 <Filename Value="../UMicroThreading.pas"/> 561 <Caret Line="7 19" Column="1" TopLine="701"/>574 <Caret Line="774" Column="1" TopLine="760"/> 562 575 </Position5> 563 576 <Position6> 564 577 <Filename Value="../UMicroThreading.pas"/> 565 <Caret Line="7 20" Column="1" TopLine="701"/>578 <Caret Line="772" Column="1" TopLine="760"/> 566 579 </Position6> 567 580 <Position7> 568 581 <Filename Value="../UMicroThreading.pas"/> 569 <Caret Line="7 18" Column="1" TopLine="701"/>582 <Caret Line="773" Column="1" TopLine="760"/> 570 583 </Position7> 571 584 <Position8> 572 585 <Filename Value="../UMicroThreading.pas"/> 573 <Caret Line="7 19" Column="1" TopLine="701"/>586 <Caret Line="774" Column="1" TopLine="760"/> 574 587 </Position8> 575 588 <Position9> 576 589 <Filename Value="../UMicroThreading.pas"/> 577 <Caret Line="7 20" Column="1" TopLine="701"/>590 <Caret Line="772" Column="1" TopLine="760"/> 578 591 </Position9> 579 592 <Position10> 580 593 <Filename Value="../UMicroThreading.pas"/> 581 <Caret Line=" 670" Column="3" TopLine="664"/>594 <Caret Line="773" Column="1" TopLine="760"/> 582 595 </Position10> 583 596 <Position11> 584 597 <Filename Value="../UMicroThreading.pas"/> 585 <Caret Line="7 06" Column="1" TopLine="693"/>598 <Caret Line="774" Column="1" TopLine="760"/> 586 599 </Position11> 587 600 <Position12> 588 601 <Filename Value="../UMicroThreading.pas"/> 589 <Caret Line="77 1" Column="3" TopLine="767"/>602 <Caret Line="772" Column="1" TopLine="760"/> 590 603 </Position12> 591 604 <Position13> 592 605 <Filename Value="../UMicroThreading.pas"/> 593 <Caret Line="7 19" Column="12" TopLine="699"/>606 <Caret Line="773" Column="1" TopLine="760"/> 594 607 </Position13> 595 608 <Position14> 596 609 <Filename Value="../UMicroThreading.pas"/> 597 <Caret Line="7 18" Column="1" TopLine="699"/>610 <Caret Line="774" Column="1" TopLine="760"/> 598 611 </Position14> 599 612 <Position15> 600 613 <Filename Value="../UMicroThreading.pas"/> 601 <Caret Line="7 19" Column="1" TopLine="699"/>614 <Caret Line="772" Column="1" TopLine="760"/> 602 615 </Position15> 603 616 <Position16> 604 617 <Filename Value="../UMicroThreading.pas"/> 605 <Caret Line="7 20" Column="1" TopLine="699"/>618 <Caret Line="773" Column="1" TopLine="760"/> 606 619 </Position16> 607 620 <Position17> 608 621 <Filename Value="../UMicroThreading.pas"/> 609 <Caret Line="7 18" Column="1" TopLine="699"/>622 <Caret Line="774" Column="1" TopLine="760"/> 610 623 </Position17> 611 624 <Position18> 612 625 <Filename Value="../UMicroThreading.pas"/> 613 <Caret Line="7 19" Column="1" TopLine="699"/>626 <Caret Line="772" Column="1" TopLine="760"/> 614 627 </Position18> 615 628 <Position19> 616 629 <Filename Value="../UMicroThreading.pas"/> 617 <Caret Line="7 20" Column="1" TopLine="699"/>630 <Caret Line="773" Column="1" TopLine="760"/> 618 631 </Position19> 619 632 <Position20> 620 633 <Filename Value="../UMicroThreading.pas"/> 621 <Caret Line="7 18" Column="1" TopLine="699"/>634 <Caret Line="774" Column="1" TopLine="760"/> 622 635 </Position20> 623 636 <Position21> 624 637 <Filename Value="../UMicroThreading.pas"/> 625 <Caret Line="7 19" Column="1" TopLine="699"/>638 <Caret Line="772" Column="1" TopLine="760"/> 626 639 </Position21> 627 640 <Position22> 628 641 <Filename Value="../UMicroThreading.pas"/> 629 <Caret Line="7 18" Column="1" TopLine="699"/>642 <Caret Line="773" Column="1" TopLine="760"/> 630 643 </Position22> 631 644 <Position23> 632 645 <Filename Value="../UMicroThreading.pas"/> 633 <Caret Line="7 19" Column="1" TopLine="699"/>646 <Caret Line="774" Column="1" TopLine="760"/> 634 647 </Position23> 635 648 <Position24> 636 649 <Filename Value="../UMicroThreading.pas"/> 637 <Caret Line=" 720" Column="1" TopLine="699"/>650 <Caret Line="810" Column="35" TopLine="796"/> 638 651 </Position24> 639 652 <Position25> 640 <Filename Value="../ UMicroThreading.pas"/>641 <Caret Line=" 718" Column="1" TopLine="699"/>653 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32object.inc"/> 654 <Caret Line="400" Column="1" TopLine="387"/> 642 655 </Position25> 643 656 <Position26> 644 657 <Filename Value="../UMicroThreading.pas"/> 645 <Caret Line=" 719" Column="1" TopLine="699"/>658 <Caret Line="524" Column="9" TopLine="513"/> 646 659 </Position26> 647 660 <Position27> 648 661 <Filename Value="../UMicroThreading.pas"/> 649 <Caret Line=" 4" Column="72" TopLine="1"/>662 <Caret Line="523" Column="1" TopLine="513"/> 650 663 </Position27> 651 664 <Position28> 652 665 <Filename Value="../UMicroThreading.pas"/> 653 <Caret Line=" 166" Column="26" TopLine="144"/>666 <Caret Line="524" Column="1" TopLine="513"/> 654 667 </Position28> 655 668 <Position29> 656 669 <Filename Value="../UMicroThreading.pas"/> 657 <Caret Line=" 670" Column="24" TopLine="654"/>670 <Caret Line="526" Column="1" TopLine="513"/> 658 671 </Position29> 659 672 <Position30> 660 <Filename Value="../ UMicroThreading.pas"/>661 <Caret Line=" 783" Column="25" TopLine="766"/>673 <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/lcl/interfaces/win32/win32object.inc"/> 674 <Caret Line="400" Column="1" TopLine="387"/> 662 675 </Position30> 663 676 </JumpHistory> … … 679 692 <StackChecks Value="True"/> 680 693 </Checks> 694 <VerifyObjMethodCallValidity Value="True"/> 681 695 </CodeGeneration> 682 696 <Linking> … … 698 712 </CompilerOptions> 699 713 <Debugging> 714 <BreakPoints Count="1"> 715 <Item1> 716 <Source Value="../UMicroThreading.pas"/> 717 <Line Value="523"/> 718 </Item1> 719 </BreakPoints> 700 720 <Watches Count="2"> 701 721 <Item1> -
MicroThreading/Demo/UMainForm.lfm
r155 r156 3 3 Height = 533 4 4 Top = 98 5 Width = 7755 Width = 816 6 6 Caption = 'MicroThreading demo' 7 7 ClientHeight = 533 8 ClientWidth = 7758 ClientWidth = 816 9 9 OnCreate = FormCreate 10 10 OnDestroy = FormDestroy … … 15 15 Height = 519 16 16 Top = 8 17 Width = 76117 Width = 802 18 18 ActivePage = TabSheet2 19 19 Anchors = [akTop, akLeft, akRight, akBottom] 20 TabIndex = 120 TabIndex = 0 21 21 TabOrder = 0 22 object TabSheet1: TTabSheet23 Caption = 'Job control'24 ClientHeight = 49325 ClientWidth = 75326 object ButtonAddWorkers: TButton27 Left = 1028 Height = 2529 Top = 730 Width = 10431 Caption = 'Add workers'32 OnClick = ButtonAddWorkersClick33 TabOrder = 034 end35 object ButtonClearMicroThreads: TButton36 Left = 1037 Height = 2538 Top = 7439 Width = 10440 Caption = 'Clear jobs'41 OnClick = ButtonClearMicroThreadsClick42 TabOrder = 143 end44 object Label4: TLabel45 Left = 12446 Height = 1447 Top = 1448 Width = 3449 Caption = 'Count:'50 ParentColor = False51 end52 object SpinEdit1: TSpinEdit53 Left = 20454 Height = 2155 Top = 1156 Width = 7457 MaxValue = 10000058 MinValue = 159 TabStop = False60 TabOrder = 261 Value = 262 end63 object Memo1: TMemo64 Left = 31665 Height = 24466 Top = 1467 Width = 29468 Anchors = [akTop, akLeft, akBottom]69 ScrollBars = ssAutoBoth70 TabOrder = 371 end72 object Button1: TButton73 Left = 1274 Height = 2575 Top = 13876 Width = 7577 Caption = 'Clear memo'78 OnClick = Button1Click79 TabOrder = 480 end81 object Label12: TLabel82 Left = 12383 Height = 1484 Top = 3885 Width = 5286 Caption = 'Iterations:'87 ParentColor = False88 end89 object SpinEdit3: TSpinEdit90 Left = 20491 Height = 2192 Top = 3693 Width = 7494 MaxValue = 100000000095 OnChange = SpinEdit3Change96 TabOrder = 597 Value = 100000098 end99 end100 22 object TabSheet2: TTabSheet 101 23 Caption = 'Scheduler state' 102 24 ClientHeight = 493 103 ClientWidth = 7 5325 ClientWidth = 794 104 26 object ListView1: TListView 105 27 Left = 222 106 28 Height = 460 107 29 Top = 24 108 Width = 47730 Width = 567 109 31 Anchors = [akTop, akLeft, akRight, akBottom] 110 32 Columns = < … … 114 36 end 115 37 item 116 Caption = 'Name'117 end118 item119 38 Caption = 'Usage' 120 39 end … … 134 53 end 135 54 item 55 Caption = 'Execution count' 56 end 57 item 136 58 Caption = 'Completion' 137 59 end … … 139 61 Caption = 'Used stack' 140 62 Width = 178 63 end 64 item 65 Caption = 'Name' 141 66 end> 142 67 OwnerData = True … … 258 183 end 259 184 end 185 object TabSheet1: TTabSheet 186 Caption = 'Job control' 187 ClientHeight = 493 188 ClientWidth = 794 189 object ButtonAddWorkers: TButton 190 Left = 10 191 Height = 25 192 Top = 7 193 Width = 104 194 Caption = 'Add workers' 195 OnClick = ButtonAddWorkersClick 196 TabOrder = 0 197 end 198 object ButtonClearMicroThreads: TButton 199 Left = 10 200 Height = 25 201 Top = 74 202 Width = 104 203 Caption = 'Clear jobs' 204 OnClick = ButtonClearMicroThreadsClick 205 TabOrder = 1 206 end 207 object Label4: TLabel 208 Left = 124 209 Height = 14 210 Top = 14 211 Width = 34 212 Caption = 'Count:' 213 ParentColor = False 214 end 215 object SpinEdit1: TSpinEdit 216 Left = 204 217 Height = 21 218 Top = 11 219 Width = 74 220 MaxValue = 100000 221 MinValue = 1 222 TabStop = False 223 TabOrder = 2 224 Value = 2 225 end 226 object Memo1: TMemo 227 Left = 316 228 Height = 244 229 Top = 14 230 Width = 294 231 Anchors = [akTop, akLeft, akBottom] 232 ScrollBars = ssAutoBoth 233 TabOrder = 3 234 end 235 object Button1: TButton 236 Left = 12 237 Height = 25 238 Top = 138 239 Width = 75 240 Caption = 'Clear memo' 241 OnClick = Button1Click 242 TabOrder = 4 243 end 244 object Label12: TLabel 245 Left = 123 246 Height = 14 247 Top = 38 248 Width = 52 249 Caption = 'Iterations:' 250 ParentColor = False 251 end 252 object SpinEdit3: TSpinEdit 253 Left = 204 254 Height = 21 255 Top = 36 256 Width = 74 257 MaxValue = 1000000000 258 OnChange = SpinEdit3Change 259 TabOrder = 5 260 Value = 10000000 261 end 262 end 260 263 object TabSheet3: TTabSheet 261 264 Caption = 'Testing' … … 313 316 top = 115 314 317 end 315 object TimerSchedulerStart: TTimer316 Interval = 10317 OnTimer = TimerSchedulerStartTimer318 left = 429319 top = 163320 end321 318 end -
MicroThreading/Demo/UMainForm.pas
r155 r156 46 46 TabSheet3: TTabSheet; 47 47 TimerRedraw: TTimer; 48 TimerSchedulerStart: TTimer;49 48 procedure Button1Click(Sender: TObject); 50 49 procedure ButtonSchedulerStartStopClick(Sender: TObject); … … 62 61 procedure SpinEdit3Change(Sender: TObject); 63 62 procedure TimerRedrawTimer(Sender: TObject); 64 procedure TimerSchedulerStartTimer(Sender: TObject);65 63 private 66 64 procedure Worker(MicroThread: TMicroThread); … … 215 213 begin 216 214 Iterations := SpinEdit3.Value; 215 SpinEdit2.Value := 20; 216 ButtonAddWorkers.Click; 217 ButtonSchedulerStartStop.Click; 217 218 end; 218 219 … … 224 225 with TMicroThread(MainScheduler.MicroThreads[Item.Index]) do begin 225 226 Item.Caption := IntToStr(Id); 226 Item.SubItems.Add(Name);227 227 Item.SubItems.Add(''); 228 228 Item.SubItems.Add(IntToStr(Priority)); … … 230 230 Item.SubItems.Add(MicroThreadBlockStateText[BlockState]); 231 231 Item.SubItems.Add(FloatToStr(ExecutionTime)); 232 Item.SubItems.Add(IntToStr(ExecutionCount)); 232 233 Item.SubItems.Add(IntToStr(Trunc(Completion * 100)) + '%'); 233 234 Item.SubItems.Add(IntToStr(StackUsed)); 235 Item.SubItems.Add(Name); 234 236 end; 235 237 finally … … 260 262 end; 261 263 262 procedure TMainForm.TimerSchedulerStartTimer(Sender: TObject);263 begin264 TimerSchedulerStart.Enabled := False;265 ButtonAddWorkers.Click;266 ButtonSchedulerStartStop.Click;267 end;268 269 264 procedure TMainForm.WorkerSubRoutine; 270 265 begin 271 MTSleep(1 * OneMillisecond);266 //MTSleep(1 * OneMillisecond); 272 267 end; 273 268 … … 282 277 Q := 0; 283 278 while Q < 100 do Inc(Q); 284 Synchronize(WorkerDoWrite);279 //Synchronize(WorkerDoWrite); 285 280 //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 286 281 // FloatToStr(ExecutionTime)); 287 282 Completion := I / Iterations; 288 //MTSleep(1 * Id* OneMillisecond);283 //MTSleep(1000 * OneMillisecond); 289 284 Yield; 290 WorkerSubRoutine;285 //WorkerSubRoutine; 291 286 end; 292 287 end; … … 295 290 procedure TMainForm.WorkerDoWrite; 296 291 begin 297 Memo1.Lines.Add('.');292 //Memo1.Lines.Add('.'); 298 293 end; 299 294 -
MicroThreading/UMicroThreading.pas
r155 r156 28 28 TMicroThreadManager = class; 29 29 30 TMicroThreadState = (ts Waiting, tsRunning, tsBlocked, tsSuspended);30 TMicroThreadState = (tsNone, tsWaiting, tsRunning, tsBlocked, tsSuspended); 31 31 TMicroThreadBlockState = (tbsNone, tbsSleeping, tbsWaitFor, tbsTerminating, 32 32 tbsTerminated); … … 58 58 FExecutionEndTime: TDateTime; 59 59 FExecutionTime: TDateTime; 60 FExecutionCount: Integer; 60 61 FStack: Pointer; 61 62 FStackPointer: Pointer; … … 73 74 function GetStackUsed: Integer; 74 75 function GetTerminated: Boolean; 76 procedure SetManager(const AValue: TMicroThreadManager); 75 77 procedure SetScheduler(const AValue: TMicroThreadScheduler); 78 procedure CheckStack; 76 79 public 77 80 Name: string; … … 97 100 property BlockState: TMicroThreadBlockState read FBlockState; 98 101 property ExecutionTime: TDateTime read FExecutionTime; 102 property ExecutionCount: Integer read FExecutionCount; 99 103 property FreeOnTerminate: Boolean read FFreeOnTerminate 100 104 write FFreeOnTerminate; … … 102 106 property Scheduler: TMicroThreadScheduler read FScheduler 103 107 write SetScheduler; 104 property Manager: TMicroThreadManager read FManager ;108 property Manager: TMicroThreadManager read FManager write SetManager; 105 109 property StackUsed: Integer read GetStackUsed; 106 110 end; … … 140 144 FScheduler: TMicroThreadScheduler; 141 145 FThread: TMicroThreadThread; 146 FId: Integer; 147 procedure SetCurrentMicroThread(const AValue: TMicroThread); 142 148 function Execute(Count: Integer): Integer; 149 property CurrentMicroThread: TMicroThread read FCurrentMicroThread 150 write SetCurrentMicroThread; 143 151 public 144 Id: Integer;145 152 procedure Yield; 146 153 procedure Synchronize(AMethod: TThreadMethod); … … 148 155 destructor Destroy; override; 149 156 property Scheduler: TMicroThreadScheduler read FScheduler; 150 property CurrentMicroThread: TMicroThread read FCurrentMicroThread;151 157 end; 152 158 … … 176 182 procedure SetActive(const AValue: Boolean); 177 183 procedure SetThreadPoolSize(const AValue: Integer); 178 function GetNextMicroThread: TMicroThread;184 procedure GetNextMicroThread(Manager: TMicroThreadManager); 179 185 procedure ReleaseMicroThread(MicroThread: TMicroThread); 180 186 procedure SetUseMainThread(const AValue: Boolean); … … 206 212 207 213 const 208 MicroThreadStateText: array[TMicroThreadState] of string = (' Waiting',214 MicroThreadStateText: array[TMicroThreadState] of string = ('None', 'Waiting', 209 215 'Running', 'Blocked', 'Suspended'); 210 216 MicroThreadBlockStateText: array[TMicroThreadBlockState] of string = ('None', … … 214 220 procedure MTSleep(Duration: TDateTime); 215 221 function MTWaitForEvent(Event: TMicroThreadEvent; Duration: TDateTime): TWaitResult; 222 procedure Log(Text: string); 223 224 const 225 LogFileName: string = 'Log.txt'; 216 226 217 227 implementation … … 284 294 end; 285 295 296 var 297 LogLock: TCriticalSection; 298 299 procedure Log(Text: string); 300 var 301 LogFile: TextFile; 302 begin 303 try 304 LogLock.Acquire; 305 AssignFile(LogFile, LogFileName); 306 if FileExists(LogFileName) then Append(LogFile) 307 else Rewrite(LogFile); 308 WriteLn(LogFile, Text); 309 CloseFile(LogFile); 310 finally 311 LogLock.Release; 312 end; 313 end; 314 286 315 { TMicroThreadMethod } 287 316 … … 323 352 324 353 { TMicroThreadManager } 354 355 procedure TMicroThreadManager.SetCurrentMicroThread(const AValue: TMicroThread 356 ); 357 begin 358 if FCurrentMicroThread = AValue then Exit; 359 if Assigned(FCurrentMicroThread) then 360 FCurrentMicroThread.FManager := nil; 361 FCurrentMicroThread := AValue; 362 if Assigned(FCurrentMicroThread) then 363 FCurrentMicroThread.FManager := Self; 364 end; 325 365 326 366 function TMicroThreadManager.Execute(Count: Integer): Integer; … … 345 385 mov eax, [ecx].TMicroThreadManager.FCurrentMicroThread 346 386 mov edx, esp 387 mov ebx, ebp 347 388 mov [eax].TMicroThread.FStackPointer, edx 348 mov edx, ebp 349 mov [eax].TMicroThread.FBasePointer, edx 350 351 // Restore FScheduler stack 389 mov [eax].TMicroThread.FBasePointer, ebx 390 391 // Restore manager stack 352 392 mov edx, [ecx].TMicroThreadManager.FStackPointer 393 mov ebx, [ecx].TMicroThreadManager.FBasePointer 353 394 mov esp, edx 354 mov edx, [ecx].TMicroThreadManager.FBasePointer 355 mov ebp, edx 395 mov ebp, ebx 356 396 end; 357 FCurrentMicroThread.FManager := nil; 397 FCurrentMicroThread.CheckStack; 398 if FCurrentMicroThread = nil then 399 raise Exception.Create('x'); 358 400 FScheduler.ReleaseMicroThread(FCurrentMicroThread); 359 FCurrentMicroThread := nil;360 401 end; 361 402 362 403 if FExecutedCount < FExecuteCount then begin 363 FCurrentMicroThread := FScheduler.GetNextMicroThread; 364 404 FScheduler.GetNextMicroThread(Self); 365 405 if Assigned(FCurrentMicroThread) then begin 366 406 Inc(FExecutedCount); 367 407 FCurrentMicroThread.FExecutionStartTime := NowPrecise; 368 FCurrentMicroThread.FManager := Self;369 408 asm 370 // Store FScheduler stack409 // Store manager stack 371 410 mov eax, Self 372 411 mov edx, esp 412 mov ebx, ebp 373 413 mov [eax].TMicroThreadManager.FStackPointer, edx 374 mov edx, ebp 375 mov [eax].TMicroThreadManager.FBasePointer, edx 414 mov [eax].TMicroThreadManager.FBasePointer, ebx 376 415 end; 377 416 if not FCurrentMicroThread.FExecuted then begin 417 // First time micro thread execution 378 418 FCurrentMicroThread.FExecuted := True; 379 419 asm … … 382 422 mov eax, [ecx].TMicroThreadManager.FCurrentMicroThread 383 423 mov edx, [eax].TMicroThread.FStackPointer 424 mov ebx, [eax].TMicroThread.FBasePointer 384 425 mov esp, edx 385 mov edx, [eax].TMicroThread.FBasePointer 386 mov ebp, edx 426 mov ebp, ebx 387 427 // We want to call virtual method Execute 388 428 // but virtual methods can be called only statically … … 390 430 call TMicroThread.CallExecute 391 431 392 // Restore FScheduler stack432 // Restore manager stack 393 433 // ecx register is set by CallExecute to running micro thread 394 434 mov eax, [ecx].TMicroThread.FManager 395 435 mov edx, [eax].TMicroThreadManager.FStackPointer 436 mov ebx, [eax].TMicroThreadManager.FBasePointer 396 437 mov esp, edx 397 mov edx, [eax].TMicroThreadManager.FBasePointer 398 mov ebp, edx 438 mov ebp, ebx 399 439 end; 400 440 FCurrentMicroThread.CheckStack; 401 441 FCurrentMicroThread.FExecutionEndTime := NowPrecise; 402 442 FCurrentMicroThread.FExecutionTime := FCurrentMicroThread.FExecutionTime + 403 443 (FCurrentMicroThread.FExecutionEndTime - FCurrentMicroThread.FExecutionStartTime); 404 FCurrentMicroThread.FState := tsBlocked;444 FCurrentMicroThread.FStatePending := tsBlocked; 405 445 FCurrentMicroThread.FBlockState := tbsTerminated; 406 446 if FCurrentMicroThread.FFreeOnTerminate then begin … … 414 454 end; 415 455 end else begin 416 FCurrentMicroThread.FManager := nil;417 456 FScheduler.ReleaseMicroThread(FCurrentMicroThread); 418 457 end; 419 458 //FCurrentMicroThread.FManager := nil; 420 459 //FScheduler.ReleaseMicroThread(FCurrentMicroThread); 421 FCurrentMicroThread := nil;460 //FCurrentMicroThread := nil; 422 461 end else 423 //if FCurrentMicroThread.State = tsWaiting then424 462 begin 425 // Execute selected thread 463 // Regular selected microthread execution 464 FCurrentMicroThread.CheckStack; 426 465 asm 427 466 // Restore microthread stack … … 429 468 mov eax, [ecx].TMicroThreadManager.FCurrentMicroThread 430 469 mov edx, [eax].TMicroThread.FStackPointer 470 mov ebx, [eax].TMicroThread.FBasePointer 431 471 mov esp, edx 432 mov edx, [eax].TMicroThread.FBasePointer 433 mov ebp, edx 472 mov ebp, ebx 434 473 end; 435 474 end; … … 464 503 try 465 504 repeat 466 ExecutedCount := Manager.Execute(10 );505 ExecutedCount := Manager.Execute(100000); 467 506 if ExecutedCount = 0 then Sleep(1); 468 507 until Terminated; 469 508 except 470 on E: Exception do 509 on E: Exception do ; 471 510 //ExceptionHandler(E); 472 511 end; … … 485 524 Terminate; 486 525 repeat 487 Application.ProcessMessages;488 526 Sleep(1); 489 527 until ExecuteTerminated; … … 522 560 end; 523 561 562 procedure TMicroThread.SetManager(const AValue: TMicroThreadManager); 563 begin 564 if FManager = AValue then Exit; 565 if Assigned(FManager) then FManager.CurrentMicroThread := nil; 566 FManager := AValue; 567 if Assigned(FManager) then FManager.CurrentMicroThread := Self; 568 end; 569 524 570 procedure TMicroThread.SetScheduler(const AValue: TMicroThreadScheduler); 525 571 begin … … 527 573 end; 528 574 575 procedure TMicroThread.CheckStack; 576 begin 577 if not ((FStackPointer > FStack) and (FStackPointer < (FStack + FStackSize))) 578 then raise EStackOverflow.Create(Format('Microthread %d stack error', [FId])); 579 end; 580 529 581 procedure TMicroThread.Execute; 530 582 begin … … 534 586 procedure TMicroThread.Yield; 535 587 begin 588 if not Assigned(FManager) then 589 raise Exception.Create('Manager reference lost'); 590 FStatePending := tsWaiting; 536 591 FManager.Yield; 537 592 end; … … 582 637 FExecutionTime := 0; 583 638 FState := tsWaiting; 584 FStatePending := ts Waiting;639 FStatePending := tsNone; 585 640 if CreateSuspended then begin 586 641 FState := tsSuspended; 587 FStatePending := tsSuspended;588 642 end; 589 643 FFreeOnTerminate := True; … … 717 771 Application.ProcessMessages; 718 772 Sleep(1); 719 until FMainThreadTerminated and (ThreadPool Size= 0);773 until FMainThreadTerminated and (ThreadPoolCount = 0); 720 774 FState := ssStopped; 721 775 end; … … 730 784 FThreadPool.OwnsObjects := False; 731 785 ThreadIndex := FThreadPool.IndexOf(Sender); 732 if ThreadIndex <> -1 then FThreadPool.Delete(ThreadIndex); 786 if ThreadIndex = -1 then 787 raise Exception.Create('Trying to free thread not found in thread pool'); 788 FThreadPool.Delete(ThreadIndex); 789 finally 733 790 FThreadPool.OwnsObjects := True; 734 finally735 791 FThreadPoolLock.Release; 736 792 end; … … 748 804 NewThread := TMicroThreadThread.Create(True); 749 805 NewThread.Manager.FScheduler := Self; 750 NewThread.Manager. Id := FThreadPool.Count + 1;806 NewThread.Manager.FId := FThreadPool.Count + 1; 751 807 NewThread.Manager.FThread := NewThread; 752 808 NewThread.OnTerminate := PoolThreadTerminated; 809 NewThread.FreeOnTerminate := True; 753 810 ThreadPool.Add(NewThread); 754 811 NewThread.Resume; … … 778 835 end; 779 836 780 function TMicroThreadScheduler.GetNextMicroThread: TMicroThread;837 procedure TMicroThreadScheduler.GetNextMicroThread(Manager: TMicroThreadManager); 781 838 var 782 839 I: Integer; 783 840 CurrentTime: TDateTime; 784 begin 785 CurrentTime := NowPrecise; 786 Result := nil; 841 Selected: TMicroThread; 842 begin 787 843 try 788 844 FMicroThreadsLock.Acquire; 845 CurrentTime := NowPrecise; 789 846 I := 0; 847 Selected := nil; 790 848 Inc(FRoundRobinIndex); 791 849 if FRoundRobinIndex >= FMicroThreads.Count then … … 793 851 while (I < FMicroThreads.Count) do 794 852 with TMicroThread(FMicroThreads[FRoundRobinIndex]) do begin 795 FState := FStatePending;796 853 if (FState = tsWaiting) then Break 797 854 else … … 815 872 // Go to next thread 816 873 Inc(I); 817 Inc(FRoundRobinIndex); 818 if FRoundRobinIndex >= FMicroThreads.Count then 819 FRoundRobinIndex := 0; 874 FRoundRobinIndex := (FRoundRobinIndex + 1) mod FMicroThreads.Count; 820 875 end; 821 876 if I < FMicroThreads.Count then begin 822 Result := TMicroThread(FMicroThreads[FRoundRobinIndex]); 823 Result.FState := tsRunning; 824 Result.FStatePending := tsWaiting; 877 if Assigned(Manager.FCurrentMicroThread) then 878 raise Exception.Create('Manager have already have running microthread'); 879 Selected := TMicroThread(FMicroThreads[FRoundRobinIndex]); 880 Selected.FState := tsRunning; 881 Inc(Selected.FExecutionCount); 825 882 end; 883 Manager.CurrentMicroThread := Selected; 826 884 finally 827 885 FMicroThreadsLock.Release; … … 831 889 procedure TMicroThreadScheduler.ReleaseMicroThread(MicroThread: TMicroThread); 832 890 begin 891 if not Assigned(MicroThread) then 892 raise Exception.Create('Can''t realease nil thread.'); 833 893 try 834 894 FMicroThreadsLock.Acquire; 835 MicroThread.FState := MicroThread.FStatePending; 895 if MicroThread.FStatePending <> tsNone then begin 896 MicroThread.FState := MicroThread.FStatePending; 897 MicroThread.FStatePending := tsNone; 898 end; 899 MicroThread.Manager := nil; 836 900 finally 837 901 FMicroThreadsLock.Release; … … 893 957 initialization 894 958 959 DeleteFile(LogFileName); 960 LogLock := TCriticalSection.Create; 895 961 MainScheduler := TMicroThreadScheduler.Create; 896 962 … … 898 964 899 965 MainScheduler.Free; 966 LogLock.Free; 900 967 901 968 end. -
MicroThreading/UPlatform.pas
r149 r156 8 8 {$IFDEF Windows}Windows,{$ENDIF} 9 9 {$IFDEF Linux}BaseUnix, UnixUtil, Unix,{$ENDIF} 10 Classes, SysUtils, DateUtils ;10 Classes, SysUtils, DateUtils, SyncObjs; 11 11 12 12 function NowPrecise: TDateTime; … … 20 20 {$ENDIF} 21 21 22 var 23 NowPreciseLock: TCriticalSection; 22 24 23 25 function NowPrecise: TDateTime; … … 26 28 {$IFDEF Windows}TimerValue: Int64;{$ENDIF} 27 29 begin 28 {$IFDEF Windows} 29 QueryPerformanceCounter(TimerValue); 30 //Result := Int64(TimeStampToMSecs(DateTimeToTimeStamp(Now)) * 1000) // an alternative Win32 timebase 31 Result := TimerValue / PerformanceFrequency; 32 {$ENDIF} 30 try 31 NowPreciseLock.Acquire; 32 {$IFDEF Windows} 33 QueryPerformanceCounter(TimerValue); 34 //Result := Int64(TimeStampToMSecs(DateTimeToTimeStamp(Now)) * 1000) // an alternative Win32 timebase 35 Result := TimerValue / PerformanceFrequency; 36 {$ENDIF} 33 37 34 {$IFDEF Linux}35 fpgettimeofday(@t, nil);36 // Build a 64 bit microsecond tick from the seconds and microsecond longints37 Result := t.tv_sec + t.tv_usec / 1000000;38 {$ENDIF}38 {$IFDEF Linux} 39 fpgettimeofday(@t, nil); 40 // Build a 64 bit microsecond tick from the seconds and microsecond longints 41 Result := t.tv_sec + t.tv_usec / 1000000; 42 {$ENDIF} 39 43 40 Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond; 44 Result := (Trunc(Now / OneSecond) + Frac(Result)) * OneSecond; 45 finally 46 NowPreciseLock.Release; 47 end; 41 48 end; 42 49 … … 58 65 QueryPerformanceFrequency(PerformanceFrequency); 59 66 {$ENDIF} 67 NowPreciseLock := TCriticalSection.Create; 68 69 finalization 70 71 NowPreciseLock.Free; 60 72 61 73 end.
Note:
See TracChangeset
for help on using the changeset viewer.