made a simple staging system

This commit is contained in:
moitoius_cp 2008-01-01 12:43:47 +00:00
parent 2fc752f3f5
commit 4fa2a3baef
4 changed files with 100 additions and 3 deletions

View file

@ -67,9 +67,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="FileSystem\Ext2.Structs.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Staging\" />
<Compile Include="Staging\DefaultStageQueue.cs" />
<Compile Include="Staging\IStage.cs" />
<Compile Include="Staging\StageQueue.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View file

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Cosmos.Kernel.Staging {
public class DefaultStageQueue : StageQueue {
public DefaultStageQueue() : base() {
}
}
}

View file

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Cosmos.Kernel.Staging {
/// <summary>
/// Represents a kernel stage.
/// </summary>
public interface IStage {
/// <summary>
/// Gets the name of the stage.
/// </summary>
string Name {
get;
}
/// <summary>
/// Initializes the stage.
/// </summary>
void Initialize();
/// <summary>
/// Tears the stage down.
/// </summary>
void Teardown();
}
}

View file

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Cosmos.Kernel.Staging {
/// <summary>
/// Represents a stage queue.
/// </summary>
public class StageQueue {
/// <summary>
/// The list of initialize stages.
/// </summary>
private Queue<IStage> _initialize = new Queue<IStage> ();
/// <summary>
/// The list of teardown stages.
/// </summary>
private Queue<IStage> _teardown = new Queue<IStage> ();
private IStage _current;
/// <summary>
/// Gets the current kernel stage.
/// </summary>
public IStage Current {
get {
return _current;
}
}
/// <summary>
/// Enqueues a stage.
/// </summary>
/// <param name="stage"></param>
public void Enqueue(IStage stage) {
_initialize.Enqueue (stage);
}
/// <summary>
/// Runs the tasks.
/// </summary>
public void Run() {
while (_initialize.Count != 0) {
_current = _initialize.Dequeue ();
_current.Initialize ();
_teardown.Enqueue (_current);
}
}
/// <summary>
/// Runs the teardown.
/// </summary>
public void Teardown() {
while (_teardown.Count != 0) {
_current = _teardown.Dequeue ();
_current.Teardown ();
}
}
}
}