Changeset 5


Ignore:
Timestamp:
Nov 23, 2014, 9:04:03 AM (10 years ago)
Author:
chronos
Message:

#1

  • Fixed: Scheduler should stop all tasks if it is stopped.
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        22ChronOS.lps
        33lib
         4heaptrclog.trc
  • trunk/Apps/UClock.pas

    r4 r5  
    66
    77uses
    8   Classes, SysUtils, UApp, dateutils;
     8  Classes, SysUtils, UApp, dateutils, UKernel;
    99
    1010type
     
    1313
    1414  TAppClock = class(TApp)
    15     procedure Run; override;
     15    procedure Run(Task: TTask); override;
    1616    constructor Create; override;
    1717  end;
     
    2121{ TAppClock }
    2222
    23 procedure TAppClock.Run;
     23procedure TAppClock.Run(Task: TTask);
    2424begin
    25   while not Terminated do begin
     25  while not Task.Terminated do begin
    2626    API.WriteText('test');
    2727    API.Sleep(OneSecond);
  • trunk/ChronOS.lpi

    r4 r5  
    1717      <StringTable ProductVersion=""/>
    1818    </VersionInfo>
    19     <BuildModes Count="1">
    20       <Item1 Name="Default" Default="True"/>
     19    <BuildModes Count="2">
     20      <Item1 Name="Debug" Default="True"/>
     21      <Item2 Name="Release">
     22        <CompilerOptions>
     23          <Version Value="11"/>
     24          <Target>
     25            <Filename Value="ChronOS"/>
     26          </Target>
     27          <SearchPaths>
     28            <IncludeFiles Value="$(ProjOutDir)"/>
     29            <OtherUnitFiles Value="Apps;Platform/Base"/>
     30            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
     31          </SearchPaths>
     32          <Parsing>
     33            <SyntaxOptions>
     34              <SyntaxMode Value="Delphi"/>
     35              <CStyleOperator Value="False"/>
     36              <AllowLabel Value="False"/>
     37              <CPPInline Value="False"/>
     38            </SyntaxOptions>
     39          </Parsing>
     40          <CodeGeneration>
     41            <SmartLinkUnit Value="True"/>
     42            <Optimizations>
     43              <OptimizationLevel Value="3"/>
     44            </Optimizations>
     45          </CodeGeneration>
     46          <Linking>
     47            <Debugging>
     48              <GenerateDebugInfo Value="False"/>
     49            </Debugging>
     50            <LinkSmart Value="True"/>
     51            <Options>
     52              <Win32>
     53                <GraphicApplication Value="True"/>
     54              </Win32>
     55            </Options>
     56          </Linking>
     57        </CompilerOptions>
     58      </Item2>
    2159    </BuildModes>
    2260    <PublishOptions>
     
    126164    </CodeGeneration>
    127165    <Linking>
     166      <Debugging>
     167        <UseHeaptrc Value="True"/>
     168      </Debugging>
    128169      <Options>
    129170        <Win32>
     
    132173      </Options>
    133174    </Linking>
     175    <Other>
     176      <CustomOptions Value="-dDEBUG"/>
     177    </Other>
    134178  </CompilerOptions>
    135179  <Debugging>
  • trunk/ChronOS.lpr

    r4 r5  
    1010  {$ENDIF}
    1111  Interfaces, // this includes the LCL widgetset
    12   Forms, UFormMain, UKernel, UFileSystem, UClock, UMemoryManager, UAPI,
     12  Forms, SysUtils, UFormMain, UKernel, UFileSystem, UClock, UMemoryManager, UAPI,
    1313  UPlatformBase, UList, UApp, UThreadEx, UMemory;
    1414
    1515{$R *.res}
    1616
     17{$IFDEF DEBUG}
     18const
     19  HeapTraceLog = 'heaptrclog.trc';
     20{$ENDIF}
     21
    1722begin
     23  {$IFDEF DEBUG}
     24  // Heap trace
     25  DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     26  SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog);
     27  {$ENDIF}
     28
    1829  RequireDerivedFormResource := True;
    1930  Application.Initialize;
  • trunk/Platform/Base/UPlatformBase.pas

    r4 r5  
    3232
    3333  TBaseScheduler = class(TScheduler)
    34     function AddTask(Name: string; EntryPoint: TBasicEvent): TTask; override;
     34    function AddTask(Name: string; EntryPoint: TTaskEvent): TTask; override;
    3535    constructor Create; override;
    3636    destructor Destroy; override;
     
    101101procedure TCustomThread.Execute;
    102102begin
    103   Task.EntryPoint;
     103  Task.EntryPoint(Task);
    104104end;
    105105
    106106{ TBaseScheduler }
    107107
    108 function TBaseScheduler.AddTask(Name: string; EntryPoint: TBasicEvent): TTask;
     108function TBaseScheduler.AddTask(Name: string; EntryPoint: TTaskEvent): TTask;
    109109var
    110110  Task: TBaseTask;
     
    135135
    136136procedure TBaseScheduler.Stop;
     137var
     138  I: Integer;
    137139begin
    138   inherited Start;
     140  inherited Stop;
     141  for I := 0 to Tasks.Count - 1 do
     142    TBaseTask(Tasks[I]).Terminated := True;
    139143end;
    140144
  • trunk/UApp.pas

    r4 r5  
    66
    77uses
    8   Classes, SysUtils, UList, UApi;
     8  Classes, SysUtils, UList, UApi, UKernel;
    99
    1010type
     
    1616    constructor Create; virtual;
    1717    destructor Destroy; override;
    18     procedure Run; virtual;
     18    procedure Run(Task: TTask); virtual;
    1919  end;
    2020
     
    3636end;
    3737
    38 procedure TApp.Run;
     38procedure TApp.Run(Task: TTask);
    3939begin
    4040
  • trunk/UKernel.pas

    r4 r5  
    99
    1010type
    11   TBasicEvent = procedure of object;
     11  TTask = class;
     12
     13  TTaskEvent = procedure(Task: TTask) of object;
    1214
    1315  TTaskState = (tsStopped, tsRunning, tsSuspended);
     
    1820    Name: string;
    1921    State: TTaskState;
    20     EntryPoint: TBasicEvent;
     22    Terminated: Boolean;
     23    EntryPoint: TTaskEvent;
    2124    constructor Create; virtual;
    2225  end;
     
    3235    procedure Start; virtual;
    3336    procedure Stop; virtual;
    34     function AddTask(Name: string; EntryPoint: TBasicEvent): TTask; virtual;
     37    function AddTask(Name: string; EntryPoint: TTaskEvent): TTask; virtual;
    3538    constructor Create; virtual;
    3639    destructor Destroy; override;
     
    3942  TSchedulerClass = class of TScheduler;
    4043
     44  { TDrive }
     45
    4146  TDrive = class(TNamedObject)
    4247    FileSystem: TFileSystem;
     48    constructor Create;
     49    destructor Destroy; override;
    4350  end;
    4451
     
    7279  UApp;
    7380
     81{ TDrive }
     82
     83constructor TDrive.Create;
     84begin
     85
     86end;
     87
     88destructor TDrive.Destroy;
     89begin
     90  FileSystem.Free;
     91  inherited Destroy;
     92end;
     93
    7494{ TDevice }
    7595
     
    103123end;
    104124
    105 function TScheduler.AddTask(Name: string; EntryPoint: TBasicEvent): TTask;
     125function TScheduler.AddTask(Name: string; EntryPoint: TTaskEvent): TTask;
    106126var
    107127  NewTask: TTask;
Note: See TracChangeset for help on using the changeset viewer.