Exemplo n.º 1
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 CallAsync2(
            TaskCode evt,
            Servicelet callbackOwner,
            task_handler callback,
            int hash = 0,
            int delay_milliseconds          = 0,
            int timer_interval_milliseconds = 0
            )
        {
            int    idx = GlobalInterOpLookupTable.Put(callback);
            IntPtr task;

            if (timer_interval_milliseconds == 0)
            {
                task = Native.dsn_task_create(evt, _c_task_handler_holder, (IntPtr)idx, hash);
            }
            else
            {
                task = Native.dsn_task_create_timer(evt, _c_task_handler_holder, (IntPtr)idx, hash, timer_interval_milliseconds);
            }

            var ret = new SafeTaskHandle(task);

            Native.dsn_task_call(task, callbackOwner != null ? callbackOwner.tracker() : IntPtr.Zero, delay_milliseconds);
            return(ret);
        }
Exemplo n.º 2
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,
            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);
        }
Exemplo n.º 3
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 CallAsync2(
            TaskCode evt,
            Clientlet callbackOwner,
            task_handler callback,
            int hash = 0,
            int delay_milliseconds          = 0,
            int timer_interval_milliseconds = 0
            )
        {
            var idx = GlobalInterOpLookupTable.Put(callback);

            var task = timer_interval_milliseconds == 0 ? Native.dsn_task_create(evt, _c_task_handler_holder, (IntPtr)idx, hash, callbackOwner?.tracker() ?? IntPtr.Zero) : Native.dsn_task_create_timer(evt, _c_timer_task_handler_holder, (IntPtr)idx, hash, timer_interval_milliseconds, callbackOwner?.tracker() ?? IntPtr.Zero);

            var ret = new SafeTaskHandle(task, idx);

            Native.dsn_task_call(task, delay_milliseconds);
            return(ret);
        }
Exemplo n.º 4
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 CallAsync2(
            TaskCode evt,
            Servicelet callbackOwner,
            task_handler callback,
            int hash = 0,
            int delay_milliseconds = 0,
            int timer_interval_milliseconds = 0
            )
        {
            int idx = GlobalInterOpLookupTable.Put(callback);
            IntPtr task;

            if (timer_interval_milliseconds == 0)
                task = Native.dsn_task_create(evt, _c_task_handler_holder, (IntPtr)idx, hash);
            else
                task = Native.dsn_task_create_timer(evt, _c_task_handler_holder, (IntPtr)idx, hash, timer_interval_milliseconds);

            var ret = new SafeTaskHandle(task);
            Native.dsn_task_call(task, callbackOwner != null ? callbackOwner.tracker() : IntPtr.Zero, delay_milliseconds);
            return ret;
        }
Exemplo n.º 5
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;
        }
Exemplo n.º 6
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 CallAsync2(
            TaskCode evt,
            Clientlet callbackOwner,
            task_handler callback,
            int hash = 0,
            int delay_milliseconds = 0,
            int timer_interval_milliseconds = 0
            )
        {
            var idx = GlobalInterOpLookupTable.Put(callback);

            var task = timer_interval_milliseconds == 0 ? Native.dsn_task_create(evt, _c_task_handler_holder, (IntPtr)idx, hash, callbackOwner?.tracker() ?? IntPtr.Zero) : Native.dsn_task_create_timer(evt, _c_timer_task_handler_holder, (IntPtr)idx, hash, timer_interval_milliseconds, callbackOwner?.tracker() ?? IntPtr.Zero);

            var ret = new SafeTaskHandle(task, idx);
            Native.dsn_task_call(task, delay_milliseconds);
            return ret;
        }