Ejemplo n.º 1
0
        void IJobProxy.JobContinueFork(System.Int32 p_0, System.Int64 p_1, JobAPI.BoxedDateTime p_2)
        {
            SerializableTaskCompletionSource rpcTask;

            // Compute size of serialized arguments
            var totalArgSize = 0;

            // Argument 0
            int arg0Size = 0;

            byte[] arg0Bytes = null;

            arg0Bytes = Ambrosia.BinarySerializer.Serialize <System.Int32>(p_0);
            arg0Size  = IntSize(arg0Bytes.Length) + arg0Bytes.Length;

            totalArgSize += arg0Size;
            // Argument 1
            int arg1Size = 0;

            byte[] arg1Bytes = null;

            arg1Bytes = Ambrosia.BinarySerializer.Serialize <System.Int64>(p_1);
            arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;

            totalArgSize += arg1Size;
            // Argument 2
            int arg2Size = 0;

            byte[] arg2Bytes = null;

            arg2Bytes = Ambrosia.BinarySerializer.Serialize <JobAPI.BoxedDateTime>(p_2);
            arg2Size  = IntSize(arg2Bytes.Length) + arg2Bytes.Length;

            totalArgSize += arg2Size;

            var wp = this.StartRPC <object>(1 /* method identifier for JobContinue */, totalArgSize, out rpcTask, RpcTypes.RpcType.FireAndForget);

            // Serialize arguments


            // Serialize arg0
            wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg0Bytes.Length);
            Buffer.BlockCopy(arg0Bytes, 0, wp.PageBytes, wp.curLength, arg0Bytes.Length);
            wp.curLength += arg0Bytes.Length;


            // Serialize arg1
            wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
            Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
            wp.curLength += arg1Bytes.Length;


            // Serialize arg2
            wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg2Bytes.Length);
            Buffer.BlockCopy(arg2Bytes, 0, wp.PageBytes, wp.curLength, arg2Bytes.Length);
            wp.curLength += arg2Bytes.Length;


            this.ReleaseBufferAndSend();
            return;
        }
Ejemplo n.º 2
0
        JobContinueAsync(System.Int32 p_0, System.Int64 p_1, JobAPI.BoxedDateTime p_2)
        {
            SerializableTaskCompletionSource rpcTask;
            // Make call, wait for reply
            // Compute size of serialized arguments
            var totalArgSize = 0;
            int arg0Size     = 0;

            byte[] arg0Bytes = null;

            // Argument 0
            arg0Bytes = Ambrosia.BinarySerializer.Serialize <System.Int32>(p_0);
            arg0Size  = IntSize(arg0Bytes.Length) + arg0Bytes.Length;

            totalArgSize += arg0Size;
            int arg1Size = 0;

            byte[] arg1Bytes = null;

            // Argument 1
            arg1Bytes = Ambrosia.BinarySerializer.Serialize <System.Int64>(p_1);
            arg1Size  = IntSize(arg1Bytes.Length) + arg1Bytes.Length;

            totalArgSize += arg1Size;
            int arg2Size = 0;

            byte[] arg2Bytes = null;

            // Argument 2
            arg2Bytes = Ambrosia.BinarySerializer.Serialize <JobAPI.BoxedDateTime>(p_2);
            arg2Size  = IntSize(arg2Bytes.Length) + arg2Bytes.Length;

            totalArgSize += arg2Size;

            var wp           = this.StartRPC <object>(methodIdentifier: 1 /* method identifier for JobContinue */, lengthOfSerializedArguments: totalArgSize, taskToWaitFor: out rpcTask);
            var asyncContext = new AsyncContext {
                SequenceNumber = Immortal.CurrentSequenceNumber
            };

            // Serialize arguments


            // Serialize arg0
            wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg0Bytes.Length);
            Buffer.BlockCopy(arg0Bytes, 0, wp.PageBytes, wp.curLength, arg0Bytes.Length);
            wp.curLength += arg0Bytes.Length;


            // Serialize arg1
            wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg1Bytes.Length);
            Buffer.BlockCopy(arg1Bytes, 0, wp.PageBytes, wp.curLength, arg1Bytes.Length);
            wp.curLength += arg1Bytes.Length;


            // Serialize arg2
            wp.curLength += wp.PageBytes.WriteInt(wp.curLength, arg2Bytes.Length);
            Buffer.BlockCopy(arg2Bytes, 0, wp.PageBytes, wp.curLength, arg2Bytes.Length);
            wp.curLength += arg2Bytes.Length;

            int taskId;

            lock (Immortal.DispatchTaskIdQueueLock)
            {
                while (!Immortal.DispatchTaskIdQueue.Data.TryDequeue(out taskId))
                {
                }
            }

            ReleaseBufferAndSend();

            Immortal.StartDispatchLoop();

            var taskToWaitFor = Immortal.CallCache.Data[asyncContext.SequenceNumber].GetAwaitableTaskWithAdditionalInfoAsync();
            var currentResult = await taskToWaitFor;

            while (currentResult.AdditionalInfoType != ResultAdditionalInfoTypes.SetResult)
            {
                switch (currentResult.AdditionalInfoType)
                {
                case ResultAdditionalInfoTypes.SaveContext:
                    await Immortal.SaveTaskContextAsync();

                    taskToWaitFor = Immortal.CallCache.Data[asyncContext.SequenceNumber].GetAwaitableTaskWithAdditionalInfoAsync();
                    break;

                case ResultAdditionalInfoTypes.TakeCheckpoint:
                    var sequenceNumber = await Immortal.TakeTaskCheckpointAsync();

                    Immortal.StartDispatchLoop();
                    taskToWaitFor = Immortal.GetTaskToWaitForWithAdditionalInfoAsync(sequenceNumber);
                    break;
                }

                currentResult = await taskToWaitFor;
            }

            lock (Immortal.DispatchTaskIdQueueLock)
            {
                Immortal.DispatchTaskIdQueue.Data.Enqueue(taskId);
            }
            return;
        }
Ejemplo n.º 3
0
 IJobProxy.JobContinueAsync(System.Int32 p_0, System.Int64 p_1, JobAPI.BoxedDateTime p_2)
 {
     await JobContinueAsync(p_0, p_1, p_2);
 }