Changeset 149 for MicroThreading/Demo/UMainForm.pas
- Timestamp:
- Jan 26, 2011, 7:12:08 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/Demo/UMainForm.pas
r148 r149 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ExtCtrls, Spin, UMicroThreading, Coroutine, DateUtils ;9 ComCtrls, ExtCtrls, Spin, UMicroThreading, Coroutine, DateUtils, UPlatform; 10 10 11 11 type … … 14 14 15 15 TMainForm = class(TForm) 16 ButtonSchedulerStartStop: TButton;17 16 Button2: TButton; 18 17 ButtonAddWorkers: TButton; 18 ButtonClearMicroThreads: TButton; 19 19 ButtonGetMaxThread: TButton; 20 ButtonSchedulerStartStop: TButton; 20 21 ButtonShowThreadId: TButton; 21 ButtonClearMicroThreads: TButton; 22 GroupBox1: TGroupBox; 23 GroupBox2: TGroupBox; 22 24 Label1: TLabel; 25 Label10: TLabel; 23 26 Label2: TLabel; 24 27 Label3: TLabel; … … 26 29 Label5: TLabel; 27 30 Label6: TLabel; 31 Label7: TLabel; 32 Label8: TLabel; 33 Label9: TLabel; 28 34 ListView1: TListView; 29 35 Memo1: TMemo; 36 PageControl1: TPageControl; 30 37 SpinEdit1: TSpinEdit; 31 38 SpinEdit2: TSpinEdit; 32 Timer1: TTimer; 39 TabSheet1: TTabSheet; 40 TabSheet2: TTabSheet; 41 TabSheet3: TTabSheet; 42 TimerRedraw: TTimer; 43 TimerSchedulerStart: TTimer; 33 44 procedure ButtonSchedulerStartStopClick(Sender: TObject); 34 45 procedure Button2Click(Sender: TObject); … … 40 51 procedure FormCreate(Sender: TObject); 41 52 procedure FormDestroy(Sender: TObject); 53 procedure FormShow(Sender: TObject); 42 54 procedure ListView1Data(Sender: TObject; Item: TListItem); 43 55 procedure SpinEdit2Change(Sender: TObject); 44 procedure Timer1Timer(Sender: TObject); 56 procedure TimerRedrawTimer(Sender: TObject); 57 procedure TimerSchedulerStartTimer(Sender: TObject); 45 58 private 46 59 procedure Worker(MicroThread: TMicroThread); … … 65 78 DoubleBuffered := True; 66 79 ListView1.DoubleBuffered := True; 67 Label6.Caption := IntToStr( Scheduler.GetCPUCoreCount);80 Label6.Caption := IntToStr(GetLogicalProcessorCount); 68 81 end; 69 82 … … 185 198 end; 186 199 200 procedure TMainForm.FormShow(Sender: TObject); 201 begin 202 end; 203 187 204 procedure TMainForm.ListView1Data(Sender: TObject; Item: TListItem); 188 205 begin … … 198 215 Item.SubItems.Add(FloatToStr(ExecutionTime)); 199 216 Item.SubItems.Add(IntToStr(Trunc(Completion * 100)) + '%'); 217 Item.SubItems.Add(IntToStr(StackUsed)); 200 218 end; 201 219 finally … … 209 227 end; 210 228 211 procedure TMainForm.Timer 1Timer(Sender: TObject);229 procedure TMainForm.TimerRedrawTimer(Sender: TObject); 212 230 begin 213 231 ListView1.Items.Count := Scheduler.MicroThreadCount; 214 232 ListView1.Items[-1]; 215 233 ListView1.Refresh; 216 Label2.Caption := DateTimeToStr(Scheduler.GetNow) + ' ' + 217 FloatToStr(Frac(Scheduler.GetNow / OneSecond)); 234 Label2.Caption := DateTimeToStr(NowPrecise) + ' ' + 235 FloatToStr(Frac(NowPrecise / OneSecond)); 236 Label9.Caption := IntToStr(Scheduler.ThreadPoolCount); 237 Label10.Caption := IntToStr(Scheduler.MicroThreadCount); 238 end; 239 240 procedure TMainForm.TimerSchedulerStartTimer(Sender: TObject); 241 begin 242 TimerSchedulerStart.Enabled := False; 243 ButtonAddWorkers.Click; 244 ButtonSchedulerStartStop.Click; 218 245 end; 219 246 … … 226 253 begin 227 254 with MicroThread do begin 228 Memo1.Lines.Add('Worker ' + IntToStr(Id));255 //Memo1.Lines.Add('Worker ' + IntToStr(Id)); 229 256 for I := 0 to TotalSteps - 1 do begin 230 257 Q := 0; 231 while Q < 10000 00do Inc(Q);258 while Q < 10000 do Inc(Q); 232 259 //Memo1.Lines.Add(IntToStr(Id) + ': ' + IntToStr(I) + ' ' + 233 260 // FloatToStr(ExecutionTime));
Note:
See TracChangeset
for help on using the changeset viewer.