static void Main(string[] args) { /************************ INITIALISATION API - PARAMETRES ********************/ Console.WriteLine("/************************ INITIALISATION API ********************/"); //construction : entrez les paramétres /* Parametre 1 = nombre threads * Parametre 2 = Protocole communication * Parametre 3 = propriété flux */ TypeCommunication typeCom = TypeCommunication.UDP; // enum UDP, TCP Property property = Property.COMPRESSED; // enum COMPRESSED, CLEAR, ENCRYPTED FluxBuilder builder = new FluxBuilder(3, typeCom, property); /************************ INITIALISATION API - CONSOLE ********************/ //création flow decorator FlowDecorator flowDecorator = builder.getResult(); // Création task executor TaskExecutor executor = new TaskExecutor(builder); flowDecorator.Executor = executor; //simulation de taches et de leur traitement int iterateurTaches = 0; Console.WriteLine("Press ESC key to stop simulation"); Console.WriteLine(); do { while (!Console.KeyAvailable) { SendMsgTask tacheX = new SendMsgTask("tache" + iterateurTaches); flowDecorator.send(new Flow(tacheX)); iterateurTaches++; Console.WriteLine("*********Nombre de taches courant : " + iterateurTaches); //on simule un laps de temps avant de recevoir d'autres atches Thread.Sleep(500); } } while (Console.ReadKey(true).Key != ConsoleKey.Escape); executor.Stop(); Console.WriteLine("Envoi des taches effectués"); }
public TaskExecutor(FluxBuilder builder) { threads = new List <Thread>(builder.getNumThread()); queue = new List <TaskCommand>(); int nbThreads = builder.getNumThread(); Console.WriteLine("*******Taille de la Pool : " + nbThreads + " threads "); Console.WriteLine(); for (int iterateurThread = 0; iterateurThread < nbThreads; iterateurThread++) { Thread newThread = new Thread(new ThreadStart(Work)) { Name = "Thread " + iterateurThread.ToString() }; newThread.Start(); threads.Add(newThread); } }
/// <summary> /// Constructs a new flux builder where the boundary conditions are /// evaluated using the convective fluxes defined by /// <paramref name="convectiveBuilder"/>. /// </summary> /// <param name="control"></param> /// <param name="boundaryMap"></param> /// <param name="speciesMap"></param> /// <param name="convectiveBuilder"></param> /// <param name="diffusiveBuilder"></param> public BoundaryConditionSourceFluxBuilder( IBMControl control, BoundaryConditionMap boundaryMap, ISpeciesMap speciesMap, FluxBuilder convectiveBuilder, FluxBuilder diffusiveBuilder) : base(control, boundaryMap, speciesMap) { standardOperator = new Operator(control); if (convectiveBuilder != null) { convectiveBuilder.BuildFluxes(standardOperator); } if (diffusiveBuilder != null) { diffusiveBuilder.BuildFluxes(standardOperator); } string levelSetBoundaryType = control.LevelSetBoundaryTag; boundaryCondition = boundaryMap.GetBoundaryCondition(levelSetBoundaryType); }