예제 #1
0
        public HyperPipe(int poolSize,
                         IRequestProvider <T> requestProvider,
                         IResponseConsumer <T> responseConsumer)
        {
            _requestProvider  = requestProvider;
            _responseConsumer = responseConsumer;

            _easyPool    = new EasyPool <T>(poolSize);
            _multiHandle = CurlNative.Multi.Init();
            if (_multiHandle.IsInvalid)
            {
                throw new Exception("Could not init curl_multi handle.");
            }

            _socketMap = new SocketPollMap();
            _loop      = new Loop();
            _timeout   = _loop.CreateTimer();

            // Explicitly define callback functions to keep them from being GCed.
            _socketCallback = HandleSocket;
            _timerCallback  = StartTimeout;

            Logger.LogDebug($"Set {CURLMoption.SOCKETFUNCTION}.");
            CurlNative.Multi.SetOpt(_multiHandle, CURLMoption.SOCKETFUNCTION, _socketCallback);
            Logger.LogDebug($"Set {CURLMoption.TIMERFUNCTION}.");
            CurlNative.Multi.SetOpt(_multiHandle, CURLMoption.TIMERFUNCTION, _timerCallback);
        }
예제 #2
0
 public static extern CURLMcode SocketAction(SafeMultiHandle multiHandle, SafeSocketHandle sockfd,
                                             CURLcselect evBitmask,
                                             out int runningHandles);
예제 #3
0
 public static extern IntPtr InfoRead(SafeMultiHandle multiHandle, out int msgsInQueue);
예제 #4
0
 public static extern CURLMcode SetOpt(SafeMultiHandle multiHandle, CURLMoption option, int value);
예제 #5
0
 public static extern CURLMcode RemoveHandle(SafeMultiHandle multiHandle, SafeEasyHandle easyHandle);
예제 #6
0
 public static extern CURLMcode SetOpt(SafeMultiHandle multiHandle, CURLMoption option,
                                       SocketCallback value);