protected override IConnectFuture Connect(Int32 port, IoHandler handler) { IoConnector connector = new LoopbackConnector(); connector.Handler = handler; return(connector.Connect(new LoopbackEndPoint(port))); }
internal void BeginConnect(IoHandler ioHandler) { if (mTcp != null) { ForceDisconnect(); } IPAddress[] address = Dns.GetHostAddresses(ip); if (address[0].AddressFamily == AddressFamily.InterNetworkV6) { mTcp = new TcpClient(AddressFamily.InterNetworkV6); } else { mTcp = new TcpClient(AddressFamily.InterNetwork); } IPAddress ipAddr = null; if (!IPAddress.TryParse(ip, out ipAddr)) { IPHostEntry entry = Dns.GetHostEntry(ip); if (entry.AddressList.Length > 0) { ipAddr = entry.AddressList[0]; } } if (ipAddr == null) { throw new Exception("IP Address error."); } Object[] args = new Object[2]; args[0] = ioHandler; args[1] = mTcp; mTcp.BeginConnect(ipAddr, port, new AsyncCallback(ConnectCallback), args); }
public void Initialise(IoHandler ioHandler, string prefix) { ProxyInstance = ProxyGenerator.CreateInterfaceProxyWithoutTarget(ResultBaseType, new ConfigurationInterceptor(ResultBaseType, ioHandler, prefix)); IsInitialised = true; }
public override Genome Start() { int cursorPosition = Console.CursorTop; int i = 0; int lastFound = 0; Genome lastBest = new Genome(null); RandomPopulation(); Console.Write(i + " iteration. Current best: "); Program.PrintParameters(BestGenome.Genes); Console.Write("with fitness: " + BestGenome.Fitness.ToString("G10")); while (BestGenome.Fitness > Settings.MinError && lastFound < Settings.MaxNoChange && i++ < Settings.MaxIter) { lastBest.Copy(BestGenome); _tempPopulation[0].Copy(BestGenome); double unused = CalculateFitness(); Parallel.For(1, Settings.PopulationSize, SingleThread); SwapBuffers(); DeterminePopulationFitness(); if (!(BestGenome.Fitness < lastBest.Fitness)) { continue; } lastFound = i; IoHandler.ClearCurrentConsoleLine(cursorPosition); Console.Write(i + " iteration. Current best: "); Program.PrintParameters(BestGenome.Genes); Console.Write("with fitness: " + BestGenome.Fitness.ToString("G10")); } return(BestGenome); }
// Constructor public Gui() { Application.Init(); ioh = new IoHandler(); win = new Window("Drawing lines"); darea = new DrawingArea(); painter = new DrawShape(DrawLine); listenOnMouse = false; // Við hlustum ekki á mús við núllstöðu. // Aukum viðburðasett teikniborðs með ,möskum'. darea.AddEvents( (int)Gdk.EventMask.PointerMotionMask | (int)Gdk.EventMask.ButtonPressMask | (int)Gdk.EventMask.ButtonReleaseMask); // Úthlutum virkni á viðburði. win.Hidden += delegate {Application.Quit();}; win.KeyPressEvent += onKeyboardPressed; darea.ExposeEvent += onDrawingAreaExposed; darea.ButtonPressEvent += onMouseClicked; darea.ButtonReleaseEvent += onMouseReleased; darea.MotionNotifyEvent += onMouseMotion; // Grunnstillum stærð glugga. win.SetDefaultSize(500,500); // Lokasamantekt til að virkja glugga. win.Add(darea); win.ShowAll(); Application.Run(); }
public override Genome Start() { int cursorPosition = Console.CursorTop; int i = 0; int lastFound = 0; int howManyDies = (int)(Settings.Mortality * Settings.PopulationSize); Genome lastBest = new Genome(null); RandomPopulation(); Console.Write(i + " iteration. Current best: "); Program.PrintParameters(BestGenome.Genes); Console.Write("with fitness: " + BestGenome.Fitness.ToString("G10")); while (BestGenome.Fitness > Settings.MinError && i++ - lastFound < Settings.MaxNoChange && i < Settings.MaxIter) { lastBest.Copy(BestGenome); for (int j = 0; j < howManyDies; j++) { ThreeTournament(j); } //Parallel.For(0, howManyDies, ThreeTournament); DetermineBestFitness(); if (!(BestGenome.Fitness < lastBest.Fitness)) { continue; } lastFound = i; IoHandler.ClearCurrentConsoleLine(cursorPosition); Console.Write(i + " iteration. Current best: "); Program.PrintParameters(BestGenome.Genes); Console.Write("with fitness: " + BestGenome.Fitness.ToString("G10")); } return(BestGenome); }
private void ConnectCallback(IAsyncResult ar) { Object[] args = (Object[])ar.AsyncState; IoHandler ioHandler = (IoHandler)args[0]; TcpClient mTcp = (TcpClient)args[1]; try { if (mTcp.Connected == true) { mTcp.EndConnect(ar); mTcp.Client.NoDelay = true; mTcp.Client.LingerState = new LingerOption(true, 0); Session session = new Session(this); session.IoHandler = ioHandler; ioHandler.ConnectReturn(session); } else { ioHandler.ConnectReturn(null); } } catch (Exception e) { logReport.OnWarningReport("ConnectCallback fail:" + e.StackTrace); ioHandler.ConnectReturn(null); } }
protected override IConnectFuture Connect(Int32 port, IoHandler handler) { IoConnector connector = new AsyncSocketConnector(); connector.Handler = handler; return(connector.Connect(new IPEndPoint(IPAddress.Loopback, port))); }
public void InitialiseAt(int index, IoHandler ioHandler, string prefix) { object instance = ProxyGenerator.CreateInterfaceProxyWithoutTarget(ResultBaseType, new InterfaceInterceptor(ResultBaseType, ioHandler, prefix)); _indexToProxyInstance[index] = instance; }
/// <summary> /// Creates an instance of the configuration interface /// </summary> /// <returns></returns> public T Build() { var handler = new IoHandler(_stores, _cacheInterval); T instance = _generator.CreateInterfaceProxyWithoutTarget <T>(new ConfigurationInterceptor <T>(handler)); return(instance); }
public override void Fire() { IoHandler ioHandler = session.IoHandler; if (ioHandler != null) { ioHandler.Closed(session); } }
/// <summary> /// Creates an instance of the configuration interface /// </summary> /// <returns></returns> public T Build() { var valueHandler = new ValueHandler(_customParsers); var ioHandler = new IoHandler(_stores, valueHandler, _cacheInterval); T instance = _generator.CreateInterfaceProxyWithoutTarget <T>(new InterfaceInterceptor(typeof(T), ioHandler)); return(instance); }
public override void Fire() { IoHandler ioHandler = session.IoHandler; if (ioHandler != null) { ioHandler.OnTimeOut(session, msg); } }
private void TimeOutProc(Msg msg, params Object[] args) { Session session = args[0] as Session; IoHandler ioHandler = session.IoHandler; if (ioHandler != null) { ioHandler.Trigger(new RevEvent(session, msg)); } logReport.OnWarningReport("msg:" + msg.Cmd + " is timeout,runtime:" + session.cmdDelegate.Runtime); }
public override void Fire() { acceptor.OnBroken(acceptor, session); IoHandler ioHandler = session.IoHandler; if (ioHandler != null) { ioHandler.Close(session); } logReport.OnWarningReport("connect is broken,notic to acceptor,sessionid:" + session.Id); }
/// <summary> /// Constructor for client-side session. /// </summary> public LoopbackSession(IoService service, LoopbackEndPoint localEP, IoHandler handler, LoopbackPipe remoteEntry) : base(service) { Config = new DefaultLoopbackSessionConfig(); _lock = new Byte[0]; _localEP = localEP; _remoteEP = remoteEntry.Endpoint; _filterChain = new LoopbackFilterChain(this); _receivedMessageQueue = new ConcurrentQueue <Object>(); _remoteSession = new LoopbackSession(this, remoteEntry); }
/// <summary> /// Constructor for client-side session. /// </summary> public LoopbackSession(IoService service, LoopbackEndPoint localEP, IoHandler handler, LoopbackPipe remoteEntry) : base(service) { Config = new DefaultLoopbackSessionConfig(); _lock = new Byte[0]; _localEP = localEP; _remoteEP = remoteEntry.Endpoint; _filterChain = new LoopbackFilterChain(this); _receivedMessageQueue = new ConcurrentQueue<Object>(); _remoteSession = new LoopbackSession(this, remoteEntry); }
private void CloseBrokerConnection() { if (_ioHandler != null) { _ioHandler.Dispose(); _ioHandler = null; } if (_connector != null) { _connector.Dispose(); _connector = null; } }
/// <summary> /// </summary> protected AbstractIoSession(IoService service) { _service = service; _handler = service.Handler; _creationTime = DateTime.Now; _lastThroughputCalculationTime = _creationTime; _lastReadTime = _lastWriteTime = _creationTime; _id = Interlocked.Increment(ref idGenerator); _closeFuture = new DefaultCloseFuture(this); _closeFuture.Complete += ResetCounter; }
/// <summary> /// Connect to the specified broker /// </summary> /// <param name="broker">The broker to connect to</param> /// <param name="connection">The AMQ connection</param> public void Connect(IBrokerInfo broker, AMQConnection connection) { _stopEvent = new ManualResetEvent(false); _protocolListener = connection.ProtocolListener; _ioHandler = MakeBrokerConnection(broker, connection); // todo: get default read size from config! IProtocolDecoderOutput decoderOutput = new ProtocolDecoderOutput(_protocolListener); _amqpChannel = new AmqpChannel(new ByteChannel(_ioHandler), decoderOutput); // post an initial async read _amqpChannel.BeginRead(new AsyncCallback(OnAsyncReadDone), this); }
private static void Solve(string[] args) { IIoHandler inputManager = new IoHandler(); var data = inputManager.GetParameters(args); IParser parser = new Parser(data); Instance instance = parser.ParseData(); if (data.ExecuteAlgorithm) { GaSettings settings = parser.ParseSettings(); IAlgorithm algorithm = new Algorithm(instance, data.Time, settings); Solution solution = algorithm.Solve(true); parser.FormatAndSaveResult(solution); } else { ConsoleHandler.CheckResources(instance); } }
static Genome Start(string[] args) { InputData inputData = IoHandler.GetParameters(args); FileHandler.ParseLines(inputData.FileName, out float[][] inputParams, out float[] desiredOutput); Ga algorithm = null; switch (inputData.Type) { case AlgorithmType.Generation: algorithm = new GenerationGa(inputParams, desiredOutput, inputData); break; case AlgorithmType.Elimination: algorithm = new EliminationGa(inputParams, desiredOutput, inputData); break; } Genome bestSolution = algorithm?.Start(); return(bestSolution); }
internal static KclProcess Create(IRecordProcessor recordProcessor, IoHandler ioHandler) { return new DefaultKclProcess(recordProcessor, ioHandler); }
public WSProtocolCodec(IoHandler ioHandler, ISocketClient socketClient) { this.ioHandler = ioHandler; this.socketClient = socketClient; }
//设置上层处理的回调 public void setHandler(IoHandler handler) { m_handle = handler; }
/// <summary> /// </summary> public void SetHandler(IoHandler handler) { _handler = handler; }
protected abstract IConnectFuture Connect(Int32 port, IoHandler handler);
/// <summary> /// </summary> protected AbstractIoService(IoSessionConfig sessionConfig) { _sessionConfig = sessionConfig; _handler = new InnerHandler(this); _stats = new IoServiceStatistics(this); }
internal static KclProcess Create(IShardRecordProcessor recordProcessor, IoHandler ioHandler) { return(new DefaultKclProcess(recordProcessor, ioHandler)); }
public Repl(IScriptEngine scriptEngine, IoHandler ioHandler) { this.scriptEngine = scriptEngine; this.ioHandler = ioHandler; }
public LoopbackPipe(LoopbackAcceptor acceptor, LoopbackEndPoint endpoint, IoHandler handler) { _acceptor = acceptor; _endpoint = endpoint; _handler = handler; }
/// <summary> /// 2 /// </summary> /// <param name="handler"></param> public void setHandler(IoHandler handler) { this._handler = handler; }
private void CloseBrokerConnection() { if ( _ioHandler != null ) { _ioHandler.Dispose(); _ioHandler = null; } if ( _connector != null ) { _connector.Dispose(); _connector = null; } }
protected override IConnectFuture Connect(Int32 port, IoHandler handler) { IoConnector connector = new LoopbackConnector(); connector.Handler = handler; return connector.Connect(new LoopbackEndPoint(port)); }
protected override IConnectFuture Connect(Int32 port, IoHandler handler) { IoConnector connector = new AsyncDatagramConnector(); connector.Handler = handler; return connector.Connect(new IPEndPoint(IPAddress.Loopback, port)); }
/// <summary> /// /// </summary> /// <param name="ioHandler"></param> /// <param name="bitSwarm"></param> public ProtocolCodec(IoHandler ioHandler, BitSwarmClient bitSwarm) { this.ioHandler = ioHandler; this.log = bitSwarm.Log; this.bitSwarm = bitSwarm; }
public SFSProtocolCodec(IoHandler ioHandler, ISocketClient bitSwarm) { this.ioHandler = ioHandler; log = bitSwarm.Log; this.bitSwarm = bitSwarm; }