Ignore:
Timestamp:
Feb 7, 2011, 1:04:27 PM (14 years ago)
Author:
george
Message:
  • Add: MicroThread critical section.
  • Add: Thread list to microthread list window.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/UMicroThreadList.pas

    r159 r162  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
    9   ExtCtrls;
     9  ExtCtrls, StdCtrls, DateUtils;
    1010
    1111type
     
    1414
    1515  TMicroThreadListForm = class(TForm)
     16    Label1: TLabel;
     17    Label2: TLabel;
    1618    ListView1: TListView;
     19    ListView2: TListView;
     20    Panel1: TPanel;
     21    Panel2: TPanel;
     22    Splitter1: TSplitter;
    1723    TimerRedraw: TTimer;
    1824    procedure FormHide(Sender: TObject);
    1925    procedure FormShow(Sender: TObject);
    2026    procedure ListView1Data(Sender: TObject; Item: TListItem);
     27    procedure ListView2Data(Sender: TObject; Item: TListItem);
    2128    procedure TimerRedrawTimer(Sender: TObject);
    2229  private
     
    3643
    3744procedure TMicroThreadListForm.TimerRedrawTimer(Sender: TObject);
     45var
     46  ThreadCount: Integer;
    3847begin
    3948  if ListView1.Items.Count <> MainScheduler.MicroThreadCount then
     
    4150  ListView1.Items[-1];
    4251  ListView1.Refresh;
     52
     53  ThreadCount := MainScheduler.ThreadPoolCount;
     54  if MainScheduler.UseMainThread then Inc(ThreadCount);
     55  if ListView2.Items.Count <> ThreadCount then
     56    ListView2.Items.Count := ThreadCount;
     57  ListView2.Items[-1];
     58  ListView2.Refresh;
    4359end;
    4460
     
    6682end;
    6783
     84procedure TMicroThreadListForm.ListView2Data(Sender: TObject; Item: TListItem);
     85var
     86  Increment: Integer;
     87begin
     88  if MainScheduler.UseMainThread then Increment := 1
     89    else Increment := 0;
     90
     91  if Item.Index < (MainScheduler.ThreadPoolCount + Increment) then begin
     92    if MainScheduler.UseMainThread and (Item.Index = 0) then begin
     93      Item.Caption := IntToStr(MainThreadID);
     94      Item.SubItems.Add('');
     95      Item.SubItems.Add(IntToStr(MainScheduler.MainThreadManager.GetCurrentMicroThreadId));
     96      Item.SubItems.Add(FloatToStr(MainScheduler.MainThreadManager.LoopDuration / OneMillisecond) + ' ms');
     97    end else
     98    try
     99      MainScheduler.ThreadPoolLock.Acquire;
     100      with TMicroThreadThread(MainScheduler.ThreadPool[Item.Index - Increment]) do begin
     101        Item.Caption := IntToStr(ThreadID);
     102        Item.SubItems.Add(MicroThreadThreadStateText[State]);
     103        Item.SubItems.Add(IntToStr(Manager.GetCurrentMicroThreadId));
     104        Item.SubItems.Add(FloatToStr(Manager.LoopDuration / OneMillisecond) + ' ms');
     105      end;
     106    finally
     107      MainScheduler.ThreadPoolLock.Release;
     108    end;
     109  end;
     110end;
     111
    68112procedure TMicroThreadListForm.FormShow(Sender: TObject);
    69113begin
Note: See TracChangeset for help on using the changeset viewer.