예제 #1
0
파일: Clientlet.cs 프로젝트: zmyer/rDSN
        //
        // this gives you the task handle so you can wait or cancel
        // the task, with the cost of add/ref the task handle
        //
        public static SafeTaskHandle RpcCallAsync2(
            RpcAddress server,
            RpcWriteStream requestStream,
            Clientlet callbackOwner,
            RpcResponseHandler callback,
            int replyHash = 0
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                            "RpcWriteStream must be flushed after write in the same thread");

            var idx  = GlobalInterOpLookupTable.Put(callback);
            var task = Native.dsn_rpc_create_response_task(
                requestStream.DangerousGetHandle(),
                _c_rpc_response_handler_holder,
                (IntPtr)idx,
                replyHash,
                callbackOwner?.tracker() ?? IntPtr.Zero
                );

            var ret = new SafeTaskHandle(task, idx);

            Native.dsn_rpc_call(server.addr, task);
            return(ret);
        }
예제 #2
0
파일: Serverlet.cs 프로젝트: zmyer/rDSN
        protected void Reply(RpcWriteStream response)
        {
            Logging.dassert(response.IsFlushed(),
                            "RpcWriteStream must be flushed after write in the same thread");

            Native.dsn_rpc_reply(response.DangerousGetHandle(), ErrorCode.ERR_OK);
        }
예제 #3
0
        // no callback
        public static void RpcCallOneWay(
            RpcAddress server,
            RpcWriteStream requestStream
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                            "RpcWriteStream must be flushed after write in the same thread");

            Native.dsn_rpc_call_one_way(server, requestStream.DangerousGetHandle());
        }
예제 #4
0
파일: Clientlet.cs 프로젝트: zmyer/rDSN
        public static RpcReadStream RpcCallSync(
            RpcAddress server,
            RpcWriteStream requestStream
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                            "RpcWriteStream must be flushed after write in the same thread");

            var respMsg = Native.dsn_rpc_call_wait(server.addr, requestStream.DangerousGetHandle());

            return(IntPtr.Zero == respMsg ? null : new RpcReadStream(respMsg, true));
        }
예제 #5
0
        public static void RpcCallAsync(
            RpcAddress server,
            RpcWriteStream requestStream,
            Servicelet callbackOwner,
            RpcResponseHandler callback,
            int replyHash = 0
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                            "RpcWriteStream must be flushed after write in the same thread");

            var        idx  = GlobalInterOpLookupTable.Put(callback);
            dsn_task_t task = Native.dsn_rpc_create_response_task(
                requestStream.DangerousGetHandle(),
                _c_rpc_response_handler_holder,
                (IntPtr)idx,
                replyHash
                );

            Native.dsn_rpc_call(server, task, callbackOwner != null ? callbackOwner.tracker() : IntPtr.Zero);
        }
예제 #6
0
        public static RpcReadStream RpcCallSync(
            RpcAddress server,
            RpcWriteStream requestStream
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                "RpcWriteStream must be flushed after write in the same thread");

            IntPtr respMsg = Native.dsn_rpc_call_wait(server, requestStream.DangerousGetHandle());
            if (IntPtr.Zero == respMsg)
            {
                return null;
            }
            else
            {
                return new RpcReadStream(respMsg, true);
            }
        }
예제 #7
0
        // no callback
        public static void RpcCallOneWay(
            RpcAddress server,
            RpcWriteStream requestStream
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                "RpcWriteStream must be flushed after write in the same thread");

            Native.dsn_rpc_call_one_way(server, requestStream.DangerousGetHandle());
        }
예제 #8
0
        //
        // this gives you the task handle so you can wait or cancel
        // the task, with the cost of add/ref the task handle
        //
        public static SafeTaskHandle RpcCallAsync2(
            RpcAddress server,
            RpcWriteStream requestStream,
            Servicelet callbackOwner,
            RpcResponseHandler callback,
            int replyHash = 0
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                "RpcWriteStream must be flushed after write in the same thread");

            var idx = GlobalInterOpLookupTable.Put(callback);
            dsn_task_t task = Native.dsn_rpc_create_response_task(
                requestStream.DangerousGetHandle(),
                _c_rpc_response_handler_holder,
                (IntPtr)idx,
                replyHash
                );

            var ret = new SafeTaskHandle(task);
            Native.dsn_rpc_call(server, task, callbackOwner != null ? callbackOwner.tracker() : IntPtr.Zero);
            return ret;
        }
예제 #9
0
파일: Clientlet.cs 프로젝트: ykwd/rDSN
        public static void RpcCallAsync(
            RpcAddress server,
            RpcWriteStream requestStream,
            Clientlet callbackOwner,
            RpcResponseHandler callback,
            int replyHash = 0
            )
        {
            Logging.dassert(requestStream.IsFlushed(),
                "RpcWriteStream must be flushed after write in the same thread");

            var idx = GlobalInterOpLookupTable.Put(callback);
            var task = Native.dsn_rpc_create_response_task(
                requestStream.DangerousGetHandle(),
                _c_rpc_response_handler_holder, 
                (IntPtr)idx, 
                replyHash,
                callbackOwner?.tracker() ?? IntPtr.Zero
                );
            Native.dsn_rpc_call(server.addr, task);
        }