private void DoAIteration(AsyncPattern target, Action done, GenCtx baseGCX) { abh.ch = new CommonHandoff(looper.Handoff.cT, looper.Handoff.bc, baseGCX); abh.done = done; //RunPrepend steps the coroutine and places it before the current one, //so we can continue running on the same frame that the child finishes (if using waitchild). abh.RunPrependRIEnumerator(target(abh)); }
public IPromise <string> RequestToken() { return(new Promise <string>((resolve, reject) => { var correlationId = new CorrelationID(); AsyncHandlers.Add(correlationId, AsyncPattern <string> .Create(resolve, reject)); Session.GenerateToken(correlationId); })); }
public IPromise <Service> Request(string uri) { return(new Promise <Service>((resolve, reject) => { var correlationId = new CorrelationID(); AsyncHandlers.Add(correlationId, AsyncPattern <Service> .Create(resolve, reject)); Session.OpenServiceAsync(uri, correlationId); })); }
public StreamingClusterDataService(string host, int port) { Host = host; StreamingPort = port; _listenerAsync = AsyncPattern.Create( (listener, pattern) => listener.BeginGetContext(pattern.OnCompleted, null), OnBeginGetContextReceived, OnBeginGetContextError); }
public RequestStreamWriter(Stream stream, Func<MemcachedCommand, MemcachedCommand> onCommandSent, Action onDisconnect) { _stream = stream; _onCommandSent = onCommandSent; _onDisconnect = onDisconnect; _writeAsync = AsyncPattern.Create( (strea, pattern) => BeginWrite(), OnBeginWriteComplete, OnBeginWriteFailed); }
public override IPromise <bool> Request(Session session, Service service, Identity identity) { return(new Promise <bool>((resolve, reject) => { var correlationId = new CorrelationID(); AsyncHandlers.Add(correlationId, AsyncPattern <bool> .Create(resolve, reject)); var request = CreateRequest(service, _clientIpAddress, _uuid); SendAuthorizationRequest(session, identity, request, correlationId); })); }
private IPromise <bool> Request(Session session, Service service, Identity identity, string token) { return(new Promise <bool>((resolve, reject) => { var correlationId = new CorrelationID(); AsyncHandlers.Add(correlationId, AsyncPattern <bool> .Create(resolve, reject)); var request = CreateRequest(service, token); SendAuthorizationRequest(session, identity, request, correlationId); })); }
public MemcachedServer(string hostName, int port) { HostName = hostName; this.Port = port; _acceptTcpClientAsync = AsyncPattern.Create((listener, pattern) => listener.BeginAcceptTcpClient(pattern.OnCompleted, null), OnTcpClient, OnAcceptError); _readAsync = AsyncPattern.Create<Stream>((stream, pattern) => stream.BeginRead(_readBuffer, _currentByteInReadBuffer, _readBuffer.Length - _currentByteInReadBuffer, pattern.OnCompleted, null), OnRead, OnReadError); try { _tcpListener = new TcpListener(new IPEndPoint(IPAddress.Any, port)); _tcpListener.Start(); _acceptTcpClientAsync.BeginAsync(_tcpListener); } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public ResponseStreamReader( Stream stream, Func<int, MemcachedCommand> commandRetriever, Action<MemcachedCommand> onCommandComplete, Action<MemcachedCommand> onError, Action onDisconnect) { _onError = onError; _onCommandComplete = onCommandComplete; _commandRetriever = commandRetriever; _onDisconnect = onDisconnect; _stream = stream; _currentReadState = ReadResponseHeader; _readAsync = AsyncPattern.Create( (strea, pattern) => strea.BeginRead(_receiveBuffer, 0, _receiveBuffer.Length, pattern.OnCompleted, null), OnBeginReadCompleted, OnBeginReadFailed); BeginReading(); }
public CouchbaseClient(string bucketName, params Server[] servers) { lock (_gate) { _reconnectMemcachedAsync = AsyncPattern.Create<TcpClient, ReconnectAttempt>( BeginMemcachedReconnection, OnMemcacachedReconnectionCompleted, OnMemcachedReconnectionError); _bucketName = bucketName; var cluster = new Cluster(); foreach (var server in servers) { cluster.AddServer(server); } BeginStreamingFromNewServersInCluster(cluster); _cluster = cluster; } }
public HttpClient(string serverId, string hostName, int port, Action<string, HttpCommand> onFailure) { ServerId = serverId; HostName = hostName; Port = port; _onFailure = onFailure; _getResponseAsync = new AsyncPattern<HttpWebRequest, HttpCommand>( (request, pattern, command) => request.BeginGetResponse(pattern.OnCompleted, command), OnBeginGetResponseCompleted, OnBeginGetResponseFailed); _readAsync = new AsyncPattern<Stream, HttpCommand>( (stream, pattern, command) => { ArraySegment<byte> buffer = command.HttpReadState.Buffer; return stream.BeginRead(buffer.Array, buffer.Offset, buffer.Count, pattern.OnCompleted, command); }, OnBeginReadCompleted, OnBeginReadFailed); }
public static SyncPattern Reexec(AsyncPattern ap) => sbh => sbh.GCX.exec.RunRIEnumerator(ap(new AsyncHandoff(sbh)));
private IAsyncResult BeginMemcachedReconnection(TcpClient tcpClient, AsyncPattern<TcpClient, ReconnectAttempt> pattern, ReconnectAttempt reconnectAttempt) { var result = tcpClient.BeginConnect( reconnectAttempt.Server.HostName, reconnectAttempt.Server.MemcachedPort, pattern.OnCompleted, reconnectAttempt); return result; }