Changeset 170


Ignore:
Timestamp:
Feb 21, 2011, 2:00:03 PM (13 years ago)
Author:
george
Message:
  • Added: Support for logging critical section lifetime.
  • Fixed: Wrong MicroThread registraction in WaitFor internal list.
Location:
MicroThreading
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/Demo/Demo.lpi

    r169 r170  
    4343      </Item3>
    4444    </RequiredPackages>
    45     <Units Count="34">
     45    <Units Count="30">
    4646      <Unit0>
    4747        <Filename Value="Demo.lpr"/>
     
    5959        <ResourceBaseClass Value="Form"/>
    6060        <UnitName Value="UMainForm"/>
    61         <EditorIndex Value="12"/>
    62         <WindowIndex Value="0"/>
    63         <TopLine Value="407"/>
    64         <CursorPos X="54" Y="428"/>
     61        <EditorIndex Value="8"/>
     62        <WindowIndex Value="0"/>
     63        <TopLine Value="284"/>
     64        <CursorPos X="44" Y="305"/>
    6565        <UsageCount Value="270"/>
    6666        <Loaded Value="True"/>
     
    7373        <EditorIndex Value="0"/>
    7474        <WindowIndex Value="0"/>
    75         <TopLine Value="449"/>
    76         <CursorPos X="1" Y="462"/>
     75        <TopLine Value="476"/>
     76        <CursorPos X="1" Y="495"/>
    7777        <UsageCount Value="136"/>
    7878        <Loaded Value="True"/>
     
    8484        <TopLine Value="1"/>
    8585        <CursorPos X="27" Y="9"/>
    86         <UsageCount Value="18"/>
     86        <UsageCount Value="5"/>
    8787      </Unit3>
    8888      <Unit4>
     
    9292        <TopLine Value="1"/>
    9393        <CursorPos X="12" Y="8"/>
    94         <UsageCount Value="25"/>
     94        <UsageCount Value="12"/>
    9595      </Unit4>
    9696      <Unit5>
     
    100100        <TopLine Value="1034"/>
    101101        <CursorPos X="14" Y="1037"/>
    102         <UsageCount Value="20"/>
     102        <UsageCount Value="7"/>
    103103      </Unit5>
    104104      <Unit6>
    105         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/classes/classesh.inc"/>
    106         <WindowIndex Value="0"/>
    107         <TopLine Value="1638"/>
    108         <CursorPos X="28" Y="1645"/>
    109         <UsageCount Value="1"/>
     105        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/win/wininc/func.inc"/>
     106        <WindowIndex Value="0"/>
     107        <TopLine Value="147"/>
     108        <CursorPos X="1" Y="158"/>
     109        <UsageCount Value="8"/>
    110110      </Unit6>
    111111      <Unit7>
    112         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/win/wininc/func.inc"/>
    113         <WindowIndex Value="0"/>
    114         <TopLine Value="147"/>
    115         <CursorPos X="1" Y="158"/>
    116         <UsageCount Value="21"/>
     112        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/sysutils/osutilsh.inc"/>
     113        <WindowIndex Value="0"/>
     114        <TopLine Value="14"/>
     115        <CursorPos X="11" Y="27"/>
     116        <UsageCount Value="9"/>
    117117      </Unit7>
    118118      <Unit8>
    119         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.4.3/fpc/2.4.3/source/rtl/objpas/sysutils/osutilsh.inc"/>
    120         <WindowIndex Value="0"/>
    121         <TopLine Value="14"/>
    122         <CursorPos X="11" Y="27"/>
    123         <UsageCount Value="22"/>
     119        <Filename Value="../UPlatform.pas"/>
     120        <UnitName Value="UPlatform"/>
     121        <EditorIndex Value="4"/>
     122        <WindowIndex Value="0"/>
     123        <TopLine Value="25"/>
     124        <CursorPos X="41" Y="39"/>
     125        <UsageCount Value="108"/>
     126        <Loaded Value="True"/>
    124127      </Unit8>
    125128      <Unit9>
    126         <Filename Value="../UPlatform.pas"/>
    127         <UnitName Value="UPlatform"/>
    128         <EditorIndex Value="3"/>
    129         <WindowIndex Value="0"/>
    130         <TopLine Value="25"/>
    131         <CursorPos X="41" Y="39"/>
    132         <UsageCount Value="42"/>
    133         <Loaded Value="True"/>
    134       </Unit9>
    135       <Unit10>
    136129        <Filename Value="../UMicroThreadList.pas"/>
    137130        <ComponentName Value="MicroThreadListForm"/>
    138131        <ResourceBaseClass Value="Form"/>
    139132        <UnitName Value="UMicroThreadList"/>
    140         <EditorIndex Value="7"/>
    141         <WindowIndex Value="0"/>
    142         <TopLine Value="121"/>
    143         <CursorPos X="10" Y="138"/>
    144         <UsageCount Value="28"/>
     133        <EditorIndex Value="6"/>
     134        <WindowIndex Value="0"/>
     135        <TopLine Value="109"/>
     136        <CursorPos X="36" Y="126"/>
     137        <UsageCount Value="94"/>
    145138        <Loaded Value="True"/>
    146139        <LoadedDesigner Value="True"/>
     140      </Unit9>
     141      <Unit10>
     142        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/sysutils/sysutilh.inc"/>
     143        <WindowIndex Value="0"/>
     144        <TopLine Value="191"/>
     145        <CursorPos X="13" Y="204"/>
     146        <UsageCount Value="7"/>
    147147      </Unit10>
    148148      <Unit11>
    149         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/sysutils/sysutilh.inc"/>
    150         <WindowIndex Value="0"/>
    151         <TopLine Value="191"/>
    152         <CursorPos X="13" Y="204"/>
    153         <UsageCount Value="20"/>
     149        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/lcl/interfaces/win32/win32object.inc"/>
     150        <WindowIndex Value="0"/>
     151        <TopLine Value="600"/>
     152        <CursorPos X="1" Y="613"/>
     153        <UsageCount Value="6"/>
    154154      </Unit11>
    155155      <Unit12>
    156         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/lcl/interfaces/win32/win32object.inc"/>
    157         <WindowIndex Value="0"/>
    158         <TopLine Value="600"/>
    159         <CursorPos X="1" Y="613"/>
    160         <UsageCount Value="19"/>
     156        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/classes/classesh.inc"/>
     157        <WindowIndex Value="0"/>
     158        <TopLine Value="1483"/>
     159        <CursorPos X="51" Y="1490"/>
     160        <UsageCount Value="6"/>
    161161      </Unit12>
    162162      <Unit13>
    163         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/classes/classesh.inc"/>
    164         <WindowIndex Value="0"/>
    165         <TopLine Value="1483"/>
    166         <CursorPos X="51" Y="1490"/>
    167         <UsageCount Value="19"/>
     163        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/win/tthread.inc"/>
     164        <WindowIndex Value="0"/>
     165        <TopLine Value="30"/>
     166        <CursorPos X="3" Y="15"/>
     167        <UsageCount Value="6"/>
    168168      </Unit13>
    169169      <Unit14>
    170         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/win/tthread.inc"/>
    171         <WindowIndex Value="0"/>
    172         <TopLine Value="30"/>
    173         <CursorPos X="3" Y="15"/>
    174         <UsageCount Value="19"/>
     170        <Filename Value="../UThreadEx.pas"/>
     171        <UnitName Value="UThreadEx"/>
     172        <EditorIndex Value="1"/>
     173        <WindowIndex Value="0"/>
     174        <TopLine Value="33"/>
     175        <CursorPos X="3" Y="37"/>
     176        <UsageCount Value="95"/>
     177        <Loaded Value="True"/>
    175178      </Unit14>
    176179      <Unit15>
    177         <Filename Value="../UThreadEx.pas"/>
    178         <UnitName Value="UThreadEx"/>
    179         <WindowIndex Value="0"/>
    180         <TopLine Value="1"/>
    181         <CursorPos X="20" Y="1"/>
    182         <UsageCount Value="29"/>
     180        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/systemh.inc"/>
     181        <WindowIndex Value="0"/>
     182        <TopLine Value="469"/>
     183        <CursorPos X="18" Y="484"/>
     184        <UsageCount Value="6"/>
    183185      </Unit15>
    184186      <Unit16>
    185         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/systemh.inc"/>
    186         <WindowIndex Value="0"/>
    187         <TopLine Value="469"/>
    188         <CursorPos X="18" Y="484"/>
    189         <UsageCount Value="19"/>
     187        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/system.inc"/>
     188        <WindowIndex Value="0"/>
     189        <TopLine Value="920"/>
     190        <CursorPos X="17" Y="942"/>
     191        <UsageCount Value="6"/>
    190192      </Unit16>
    191193      <Unit17>
    192         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/system.inc"/>
    193         <WindowIndex Value="0"/>
    194         <TopLine Value="920"/>
    195         <CursorPos X="17" Y="942"/>
    196         <UsageCount Value="19"/>
     194        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/sysutils/osutilsh.inc"/>
     195        <WindowIndex Value="0"/>
     196        <TopLine Value="14"/>
     197        <CursorPos X="11" Y="27"/>
     198        <UsageCount Value="6"/>
    197199      </Unit17>
    198200      <Unit18>
    199         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/sysutils/osutilsh.inc"/>
    200         <WindowIndex Value="0"/>
    201         <TopLine Value="14"/>
    202         <CursorPos X="11" Y="27"/>
    203         <UsageCount Value="19"/>
     201        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/threadh.inc"/>
     202        <WindowIndex Value="0"/>
     203        <TopLine Value="57"/>
     204        <CursorPos X="5" Y="70"/>
     205        <UsageCount Value="6"/>
    204206      </Unit18>
    205207      <Unit19>
    206         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/threadh.inc"/>
    207         <WindowIndex Value="0"/>
    208         <TopLine Value="57"/>
    209         <CursorPos X="5" Y="70"/>
    210         <UsageCount Value="19"/>
     208        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/thread.inc"/>
     209        <WindowIndex Value="0"/>
     210        <TopLine Value="169"/>
     211        <CursorPos X="33" Y="184"/>
     212        <UsageCount Value="6"/>
    211213      </Unit19>
    212214      <Unit20>
    213         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/thread.inc"/>
    214         <WindowIndex Value="0"/>
    215         <TopLine Value="169"/>
    216         <CursorPos X="33" Y="184"/>
    217         <UsageCount Value="19"/>
     215        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/sysutils/sysutils.inc"/>
     216        <WindowIndex Value="0"/>
     217        <TopLine Value="429"/>
     218        <CursorPos X="19" Y="435"/>
     219        <UsageCount Value="5"/>
    218220      </Unit20>
    219221      <Unit21>
    220         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/objpas/sysutils/sysutils.inc"/>
    221         <WindowIndex Value="0"/>
    222         <TopLine Value="429"/>
    223         <CursorPos X="19" Y="435"/>
    224         <UsageCount Value="18"/>
     222        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/objpash.inc"/>
     223        <WindowIndex Value="0"/>
     224        <TopLine Value="329"/>
     225        <CursorPos X="14" Y="342"/>
     226        <UsageCount Value="5"/>
    225227      </Unit21>
    226228      <Unit22>
    227         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/objpash.inc"/>
    228         <WindowIndex Value="0"/>
    229         <TopLine Value="329"/>
    230         <CursorPos X="14" Y="342"/>
    231         <UsageCount Value="18"/>
     229        <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/except.inc"/>
     230        <WindowIndex Value="0"/>
     231        <TopLine Value="29"/>
     232        <CursorPos X="23" Y="42"/>
     233        <UsageCount Value="2"/>
    232234      </Unit22>
    233235      <Unit23>
    234         <Filename Value="../../../../Programy/Lazarus/0.9.31_2.5.1/fpc/2.5.1/source/rtl/inc/except.inc"/>
    235         <WindowIndex Value="0"/>
    236         <TopLine Value="29"/>
    237         <CursorPos X="23" Y="42"/>
    238         <UsageCount Value="15"/>
     236        <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/packages/fcl-base/src/syncobjs.pp"/>
     237        <UnitName Value="syncobjs"/>
     238        <WindowIndex Value="0"/>
     239        <TopLine Value="35"/>
     240        <CursorPos X="18" Y="45"/>
     241        <UsageCount Value="4"/>
    239242      </Unit23>
    240243      <Unit24>
    241         <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/packages/fcl-base/src/syncobjs.pp"/>
    242         <UnitName Value="syncobjs"/>
    243         <EditorIndex Value="11"/>
    244         <WindowIndex Value="0"/>
    245         <TopLine Value="35"/>
    246         <CursorPos X="18" Y="45"/>
    247         <UsageCount Value="17"/>
     244        <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/customlistview.inc"/>
     245        <EditorIndex Value="5"/>
     246        <WindowIndex Value="0"/>
     247        <TopLine Value="548"/>
     248        <CursorPos X="1" Y="561"/>
     249        <UsageCount Value="82"/>
    248250        <Loaded Value="True"/>
    249251      </Unit24>
    250252      <Unit25>
    251         <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/customlistview.inc"/>
    252         <EditorIndex Value="4"/>
    253         <WindowIndex Value="0"/>
    254         <TopLine Value="548"/>
    255         <CursorPos X="1" Y="561"/>
    256         <UsageCount Value="16"/>
    257         <Loaded Value="True"/>
     253        <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/listitem.inc"/>
     254        <WindowIndex Value="0"/>
     255        <TopLine Value="798"/>
     256        <CursorPos X="1" Y="821"/>
     257        <UsageCount Value="3"/>
    258258      </Unit25>
    259259      <Unit26>
    260         <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/listitem.inc"/>
    261         <EditorIndex Value="5"/>
    262         <WindowIndex Value="0"/>
    263         <TopLine Value="798"/>
    264         <CursorPos X="1" Y="821"/>
    265         <UsageCount Value="16"/>
    266         <Loaded Value="True"/>
     260        <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/listitems.inc"/>
     261        <WindowIndex Value="0"/>
     262        <TopLine Value="65"/>
     263        <CursorPos X="29" Y="75"/>
     264        <UsageCount Value="3"/>
    267265      </Unit26>
    268266      <Unit27>
    269         <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/listitems.inc"/>
    270         <EditorIndex Value="6"/>
    271         <WindowIndex Value="0"/>
    272         <TopLine Value="65"/>
    273         <CursorPos X="29" Y="75"/>
    274         <UsageCount Value="16"/>
     267        <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/forms.pp"/>
     268        <UnitName Value="Forms"/>
     269        <EditorIndex Value="2"/>
     270        <WindowIndex Value="0"/>
     271        <TopLine Value="1398"/>
     272        <CursorPos X="15" Y="1309"/>
     273        <UsageCount Value="81"/>
    275274        <Loaded Value="True"/>
    276275      </Unit27>
    277276      <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="15"/>
     277        <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/Lazarus/lcl/include/application.inc"/>
     278        <EditorIndex Value="3"/>
     279        <WindowIndex Value="0"/>
     280        <TopLine Value="2161"/>
     281        <CursorPos X="33" Y="2161"/>
     282        <UsageCount Value="81"/>
    285283        <Loaded Value="True"/>
    286284      </Unit28>
    287285      <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="15"/>
    294         <Loaded Value="True"/>
    295       </Unit29>
    296       <Unit30>
    297286        <Filename Value="../UMicroThreadCallStack.pas"/>
    298287        <ComponentName Value="CallStackForm"/>
    299288        <ResourceBaseClass Value="Form"/>
    300289        <UnitName Value="UMicroThreadCallStack"/>
    301         <EditorIndex Value="8"/>
     290        <EditorIndex Value="7"/>
    302291        <WindowIndex Value="0"/>
    303292        <TopLine Value="44"/>
    304293        <CursorPos X="22" Y="66"/>
    305         <UsageCount Value="14"/>
     294        <UsageCount Value="80"/>
    306295        <Loaded Value="True"/>
    307296        <LoadedDesigner Value="True"/>
    308       </Unit30>
    309       <Unit31>
    310         <Filename Value="../UStackTrace.pas"/>
    311         <UnitName Value="UStackTrace"/>
    312         <WindowIndex Value="0"/>
    313         <TopLine Value="17"/>
    314         <CursorPos X="26" Y="122"/>
    315         <UsageCount Value="11"/>
    316       </Unit31>
    317       <Unit32>
    318         <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/rtl/inc/systemh.inc"/>
    319         <EditorIndex Value="9"/>
    320         <WindowIndex Value="0"/>
    321         <TopLine Value="974"/>
    322         <CursorPos X="10" Y="987"/>
    323         <UsageCount Value="11"/>
    324         <Loaded Value="True"/>
    325       </Unit32>
    326       <Unit33>
    327         <Filename Value="../../../../Projekty2/FreePascalManager/trunk/Instance/1/FPC/rtl/i386/i386.inc"/>
    328         <EditorIndex Value="10"/>
    329         <WindowIndex Value="0"/>
    330         <TopLine Value="1135"/>
    331         <CursorPos X="10" Y="1139"/>
    332         <UsageCount Value="11"/>
    333         <Loaded Value="True"/>
    334       </Unit33>
     297      </Unit29>
    335298    </Units>
    336     <JumpHistory Count="14" HistoryIndex="13">
     299    <JumpHistory Count="30" HistoryIndex="29">
    337300      <Position1>
    338301        <Filename Value="../UMicroThreading.pas"/>
    339         <Caret Line="854" Column="3" TopLine="847"/>
     302        <Caret Line="407" Column="41" TopLine="400"/>
    340303      </Position1>
    341304      <Position2>
    342305        <Filename Value="../UMicroThreading.pas"/>
    343         <Caret Line="853" Column="41" TopLine="847"/>
     306        <Caret Line="381" Column="36" TopLine="371"/>
    344307      </Position2>
    345308      <Position3>
    346309        <Filename Value="../UMicroThreading.pas"/>
    347         <Caret Line="854" Column="1" TopLine="847"/>
     310        <Caret Line="492" Column="26" TopLine="480"/>
    348311      </Position3>
    349312      <Position4>
    350313        <Filename Value="../UMicroThreading.pas"/>
    351         <Caret Line="855" Column="1" TopLine="847"/>
     314        <Caret Line="489" Column="1" TopLine="480"/>
    352315      </Position4>
    353316      <Position5>
    354         <Filename Value="../UMicroThreadCallStack.pas"/>
    355         <Caret Line="67" Column="38" TopLine="46"/>
     317        <Filename Value="../UMicroThreading.pas"/>
     318        <Caret Line="490" Column="1" TopLine="480"/>
    356319      </Position5>
    357320      <Position6>
    358         <Filename Value="../UMicroThreadCallStack.pas"/>
    359         <Caret Line="66" Column="19" TopLine="47"/>
     321        <Filename Value="../UMicroThreading.pas"/>
     322        <Caret Line="491" Column="1" TopLine="480"/>
    360323      </Position6>
    361324      <Position7>
    362         <Filename Value="../UMicroThreadCallStack.pas"/>
    363         <Caret Line="67" Column="14" TopLine="47"/>
     325        <Filename Value="../UMicroThreading.pas"/>
     326        <Caret Line="492" Column="1" TopLine="480"/>
    364327      </Position7>
    365328      <Position8>
    366         <Filename Value="../UMicroThreadCallStack.pas"/>
    367         <Caret Line="66" Column="22" TopLine="44"/>
     329        <Filename Value="../UMicroThreading.pas"/>
     330        <Caret Line="493" Column="1" TopLine="480"/>
    368331      </Position8>
    369332      <Position9>
    370         <Filename Value="../UMicroThreadList.pas"/>
    371         <Caret Line="138" Column="10" TopLine="121"/>
     333        <Filename Value="../UMicroThreading.pas"/>
     334        <Caret Line="489" Column="1" TopLine="480"/>
    372335      </Position9>
    373336      <Position10>
    374         <Filename Value="UMainForm.pas"/>
    375         <Caret Line="428" Column="43" TopLine="411"/>
     337        <Filename Value="../UMicroThreading.pas"/>
     338        <Caret Line="490" Column="1" TopLine="480"/>
    376339      </Position10>
    377340      <Position11>
    378         <Filename Value="UMainForm.pas"/>
    379         <Caret Line="116" Column="33" TopLine="103"/>
     341        <Filename Value="../UMicroThreading.pas"/>
     342        <Caret Line="491" Column="1" TopLine="480"/>
    380343      </Position11>
    381344      <Position12>
    382         <Filename Value="UMainForm.pas"/>
    383         <Caret Line="305" Column="44" TopLine="284"/>
     345        <Filename Value="../UMicroThreading.pas"/>
     346        <Caret Line="498" Column="1" TopLine="480"/>
    384347      </Position12>
    385348      <Position13>
    386         <Filename Value="UMainForm.pas"/>
    387         <Caret Line="399" Column="54" TopLine="378"/>
     349        <Filename Value="../UMicroThreading.pas"/>
     350        <Caret Line="500" Column="1" TopLine="480"/>
    388351      </Position13>
    389352      <Position14>
    390         <Filename Value="UMainForm.pas"/>
    391         <Caret Line="428" Column="54" TopLine="407"/>
     353        <Filename Value="../UMicroThreading.pas"/>
     354        <Caret Line="502" Column="1" TopLine="480"/>
    392355      </Position14>
     356      <Position15>
     357        <Filename Value="../UMicroThreading.pas"/>
     358        <Caret Line="489" Column="1" TopLine="480"/>
     359      </Position15>
     360      <Position16>
     361        <Filename Value="../UMicroThreading.pas"/>
     362        <Caret Line="490" Column="1" TopLine="480"/>
     363      </Position16>
     364      <Position17>
     365        <Filename Value="../UMicroThreading.pas"/>
     366        <Caret Line="491" Column="1" TopLine="480"/>
     367      </Position17>
     368      <Position18>
     369        <Filename Value="../UMicroThreading.pas"/>
     370        <Caret Line="513" Column="1" TopLine="508"/>
     371      </Position18>
     372      <Position19>
     373        <Filename Value="../UMicroThreading.pas"/>
     374        <Caret Line="514" Column="1" TopLine="508"/>
     375      </Position19>
     376      <Position20>
     377        <Filename Value="../UMicroThreading.pas"/>
     378        <Caret Line="515" Column="1" TopLine="508"/>
     379      </Position20>
     380      <Position21>
     381        <Filename Value="../UMicroThreading.pas"/>
     382        <Caret Line="516" Column="1" TopLine="508"/>
     383      </Position21>
     384      <Position22>
     385        <Filename Value="../UMicroThreading.pas"/>
     386        <Caret Line="517" Column="1" TopLine="508"/>
     387      </Position22>
     388      <Position23>
     389        <Filename Value="../UMicroThreading.pas"/>
     390        <Caret Line="521" Column="25" TopLine="508"/>
     391      </Position23>
     392      <Position24>
     393        <Filename Value="../UMicroThreading.pas"/>
     394        <Caret Line="513" Column="1" TopLine="508"/>
     395      </Position24>
     396      <Position25>
     397        <Filename Value="../UMicroThreading.pas"/>
     398        <Caret Line="489" Column="1" TopLine="476"/>
     399      </Position25>
     400      <Position26>
     401        <Filename Value="../UMicroThreading.pas"/>
     402        <Caret Line="490" Column="1" TopLine="476"/>
     403      </Position26>
     404      <Position27>
     405        <Filename Value="../UMicroThreading.pas"/>
     406        <Caret Line="491" Column="1" TopLine="476"/>
     407      </Position27>
     408      <Position28>
     409        <Filename Value="../UMicroThreading.pas"/>
     410        <Caret Line="492" Column="1" TopLine="476"/>
     411      </Position28>
     412      <Position29>
     413        <Filename Value="../UMicroThreading.pas"/>
     414        <Caret Line="493" Column="1" TopLine="476"/>
     415      </Position29>
     416      <Position30>
     417        <Filename Value="../UMicroThreading.pas"/>
     418        <Caret Line="494" Column="1" TopLine="476"/>
     419      </Position30>
    393420    </JumpHistory>
    394421  </ProjectOptions>
  • MicroThreading/UMicroThreading.pas

    r169 r170  
    5353  TMicroThreadCriticalSection = class
    5454  private
     55    FId: Integer;
    5556    FMicroThreads: TObjectList;
    56     Lock: TCriticalSection;
     57    //Lock: TCriticalSection;
    5758    FCounter: Integer;
    5859  public
     
    6162    constructor Create;
    6263    destructor Destroy; override;
     64    property Id: Integer read FId;
    6365  end;
    6466
     
    208210    FThreadPoolSize: Integer;
    209211    FRoundRobinIndex: Integer;
    210     FLastId: Integer;
     212    FMicroThreadLastId: Integer;
     213    FCriticalSectionLastId: Integer;
    211214    FMainThreadTerminated: Boolean;
    212215    FMicroThreads: TObjectList; // TList<TMicroThread>
     
    232235    procedure MainThreadStart(Sender: TObject);
    233236    procedure MainThreadTick(Data: PtrInt);
     237    function GetCriticalSectionId: Integer;
    234238  public
    235239    BurstCount: Integer;
    236240    function Add(MicroThread: TMicroThread): Integer;
    237     function AddMethod(Method: TProcedureOfObject; WaitForFinish: Boolean = True): Integer;
     241    function AddMethod(Method: TProcedureOfObject;
     242      WaitForFinish: Boolean = True; ThreadName: string = ''): Integer;
    238243    procedure Remove(MicroThread: TMicroThread; Free: Boolean = True);
    239244    constructor Create;
     
    282287const
    283288  LogFileName: string = 'Log.txt';
     289  LogEnabled: Boolean = False;
    284290
    285291implementation
     
    350356  LogFile: TextFile;
    351357begin
     358  if LogEnabled then
    352359  try
    353360    LogLock.Acquire;
     
    373380  try
    374381    MainScheduler.FMicroThreadsLock.Acquire;
    375     Lock.Acquire;
     382    {$IFDEF DebugCriticalSection}
     383    Log('CriticalSection(' + IntToStr(FId) + ') Acquire start, MicroThread: ' + IntToStr(MT.Id) + '(' + MT.Name + ')');
     384    {$ENDIF}
     385    //Lock.Acquire;
    376386    Inc(FCounter);
     387    {$IFDEF DebugCriticalSection}
     388    Log('CriticalSection(' + IntToStr(FId) + ') Acquire Counter: ' + IntToStr(FCounter));
     389    {$ENDIF}
    377390    if FCounter > 1 then begin
    378391      FMicroThreads.Add(MT);
     
    380393      MT.FStatePending := tsBlocked;
    381394      try
    382         Lock.Release;
     395        //Lock.Release;
    383396        MainScheduler.FMicroThreadsLock.Release;
    384397        MT.Yield;
    385398      finally
    386399        MainScheduler.FMicroThreadsLock.Acquire;
    387         Lock.Acquire;
     400        //Lock.Acquire;
    388401      end;
    389402    end;
    390403  finally
    391     Lock.Release;
     404    {$IFDEF DebugCriticalSection}
     405    Log('CriticalSection(' + IntToStr(FId) + ') Acquire end: Id:' + IntToStr(MT.Id) + ' Name:' + MT.Name);
     406    {$ENDIF}
     407    //Lock.Release;
    392408    MainScheduler.FMicroThreadsLock.Release;
    393409  end else
     
    396412
    397413procedure TMicroThreadCriticalSection.Release;
     414var
     415  MT: TMicroThread;
    398416begin
    399417  try
    400418    MainScheduler.FMicroThreadsLock.Acquire;
    401     Lock.Acquire;
     419    {$IFDEF DebugCriticalSection}
     420    MT := GetCurrentMicroThread;
     421    if Assigned(MT) then
     422      Log('CriticalSection(' + IntToStr(FId) + ') Release start: Id:' + IntToStr(MT.Id) + ' Name:' + MT.Name)
     423      else Log('CriticalSection(' + IntToStr(FId) + ') Release start: no microthread');
     424    {$ENDIF}
     425    //Lock.Acquire;
    402426    Dec(FCounter);
     427    {$IFDEF DebugCriticalSection}
     428    Log('CriticalSection(' + IntToStr(FId) + ') Release Counter: ' + IntToStr(FCounter));
     429    {$ENDIF}
    403430    if FMicroThreads.Count > 0 then begin
    404431      // Release one waiting micro thread
     
    410437      raise EMicroThreadError.Create(SCriticalSectionDecrement);
    411438  finally
    412     Lock.Release;
     439    {$IFDEF DebugCriticalSection}
     440    Log('CriticalSection(' + IntToStr(FId) + ') Release end: Id:' + IntToStr(MT.Id) + ' Name:' + MT.Name);
     441    {$ENDIF}
     442    //Lock.Release;
    413443    MainScheduler.FMicroThreadsLock.Release;
    414444  end;
     
    417447constructor TMicroThreadCriticalSection.Create;
    418448begin
    419   Lock := TCriticalSection.Create;
     449  //Lock := TCriticalSection.Create;
    420450  FMicroThreads := TObjectList.Create;
    421451  FMicroThreads.OwnsObjects := False;
     452  FId := MainScheduler.GetCriticalSectionId;
    422453end;
    423454
     
    426457  try
    427458    MainScheduler.FMicroThreadsLock.Acquire;
    428     Lock.Acquire;
     459    //Lock.Acquire;
    429460
    430461    while FMicroThreads.Count > 0 do begin
     
    434465    end;
    435466  finally
    436     Lock.Release;
     467    //Lock.Release;
    437468    MainScheduler.FMicroThreadsLock.Release;
    438469  end;
    439470  FMicroThreads.Free;
    440   Lock.Free;
     471  //Lock.Free;
    441472  inherited Destroy;
    442473end;
     
    488519        Exit;
    489520      end;
    490       FMicroThreads.Add(Self);
     521      FMicroThreads.Add(MT);
    491522      MT.FBlockTime := NowPrecise + Duration;
    492523      MT.FBlockState := tbsWaitFor;
     
    798829procedure TMicroThread.Yield;
    799830begin
    800 //  if not Assigned(FManager) then
    801 //    raise EMicroThreadError.Create(SManagerReferenceLost);
     831  if not Assigned(FManager) then
     832    raise EMicroThreadError.Create(SManagerReferenceLost);
    802833  if FStatePending = tsNone then
    803834    FStatePending := tsWaiting;
     
    896927  try
    897928    FMicroThreadsLock.Acquire;
    898     Inc(FLastId);
     929    Inc(FMicroThreadLastId);
     930    MicroThread.FId := FMicroThreadLastId;
    899931    MicroThread.FScheduler := Self;
    900     MicroThread.FId := FLastId;
    901932    Result := FMicroThreads.Add(MicroThread);
    902933  finally
     
    905936end;
    906937
    907 function TMicroThreadScheduler.AddMethod(Method: TProcedureOfObject; WaitForFinish: Boolean): Integer;
     938function TMicroThreadScheduler.AddMethod(Method: TProcedureOfObject;
     939  WaitForFinish: Boolean = True; ThreadName: string = ''): Integer;
    908940var
    909941  NewMicroThread: TMicroThreadSimple;
     
    912944  try
    913945    NewMicroThread := TMicroThreadSimple.Create(True);
     946    NewMicroThread.Name := ThreadName;
    914947    NewMicroThread.Method := Method;
    915948    NewMicroThread.FScheduler := Self;
     
    10831116//  end;
    10841117  FMainThreadOutsideStart := NowPrecise;
     1118end;
     1119
     1120function TMicroThreadScheduler.GetCriticalSectionId: Integer;
     1121begin
     1122  Inc(FCriticalSectionLastId);
     1123  Result := FCriticalSectionLastId;
    10851124end;
    10861125
Note: See TracChangeset for help on using the changeset viewer.