Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1815 for trunk


Ignore:
Timestamp:
05/14/09 17:12:03 (15 years ago)
Author:
swagner
Message:

Added a property for the thread priority of an engine's worker thread to EngineBase (#623)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.2/EngineBase.cs

    r1529 r1815  
    6767    }
    6868
     69    private ThreadPriority myPriority;
     70    /// <summary>
     71    /// Gets or sets the priority of the worker thread.
     72    /// </summary>
     73    public ThreadPriority Priority {
     74      get { return myPriority; }
     75      set { myPriority = value; }
     76    }
     77
    6978    /// <summary>
    7079    /// Field of the current instance that represent the execution stack.
     
    113122      myOperatorGraph = new OperatorGraph();
    114123      myGlobalScope = new Scope("Global");
     124      myPriority = ThreadPriority.Normal;
    115125      myExecutionStack = new Stack<IOperation>();
    116126      Reset();
     
    183193
    184194    private void Run(object state) {
     195      Thread.CurrentThread.Priority = Priority;
    185196      if (state == null) Run();
    186197      else RunSteps((int)state);
    187198      myRunning = false;
     199      Thread.CurrentThread.Priority = ThreadPriority.Normal;
    188200      OnFinished();
    189201    }
     
    302314    /// time is saved as string in the node's inner text.</description>
    303315    /// </item>
     316    /// <item>
     317    /// <term>Priority: </term>
     318    /// <description>Saved as a child node with the tag name <c>Priority</c>, where the thread priority
     319    /// is saved as string in the node's inner text.</description>
     320    /// </item>
    304321    /// </list></remarks>
    305322    /// <param name="name">The (tag)name of the <see cref="XmlNode"/>.</param>
     
    323340      timeNode.InnerText = ExecutionTime.ToString();
    324341      node.AppendChild(timeNode);
     342      XmlNode priorityNode = document.CreateNode(XmlNodeType.Element, "Priority", null);
     343      priorityNode.InnerText = Priority.ToString();
     344      node.AppendChild(priorityNode);
    325345      return node;
    326346    }
     
    344364      XmlNode timeNode = node.SelectSingleNode("ExecutionTime");
    345365      myExecutionTime = TimeSpan.Parse(timeNode.InnerText);
     366      XmlNode priorityNode = node.SelectSingleNode("Priority");
     367      if (priorityNode != null)
     368        myPriority = (ThreadPriority) Enum.Parse(typeof(ThreadPriority), priorityNode.InnerText);
    346369    }
    347370    #endregion
  • trunk/sources/HeuristicLab.Core/3.2/Interfaces/IEngine.cs

    r776 r1815  
    2323using System.Collections.Generic;
    2424using System.Text;
     25using System.Threading;
    2526
    2627namespace HeuristicLab.Core {
     
    4445    /// </summary>
    4546    TimeSpan ExecutionTime { get; }
     47    /// <summary>
     48    /// Gets or sets the thread priority of the worker thread.
     49    /// </summary>
     50    ThreadPriority Priority { get; set; }
    4651
    4752    /// <summary>
  • trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs

    r1773 r1815  
    6262    }
    6363
     64    public ThreadPriority Priority {
     65      get { return job.Engine.Priority; }
     66      set { job.Engine.Priority = value; }
     67    }
     68
    6469    public bool Running {
    6570      get { return job.Engine.Running; }
  • trunk/sources/HeuristicLab.Hive.Engine/3.2/Job.cs

    r1761 r1815  
    4242      : base() {
    4343      engine = new SequentialEngine.SequentialEngine();
     44      engine.Priority = ThreadPriority.Lowest;
    4445      RegisterEvents();
    4546    }
Note: See TracChangeset for help on using the changeset viewer.