Exemple #1
0
 /// <summary>
 /// Finishes marshal session for this request (if any).
 /// </summary>
 public void FinishMarshal()
 {
     if (_writer != null)
     {
         Marshaller.FinishMarshal(_writer);
     }
 }
        /// <summary>
        /// Writes to stream.
        /// </summary>
        private static void WriteToStream <T>(T obj, IBinaryStream stream, Marshaller marsh)
        {
            var writer = marsh.StartMarshal(stream);

            writer.WriteObject(obj);

            marsh.FinishMarshal(writer);
        }
Exemple #3
0
        /// <summary>
        /// Writes to stream.
        /// </summary>
        private static void WriteToStream(Action <BinaryWriter> action, IBinaryStream stream, Marshaller marsh)
        {
            var writer = marsh.StartMarshal(stream);

            action(writer);

            marsh.FinishMarshal(writer);
        }
        /// <summary>
        /// Writes to stream.
        /// </summary>
        private static bool WriteToStream(Func <BinaryWriter, bool> action, IBinaryStream stream, Marshaller marsh)
        {
            var writer = marsh.StartMarshal(stream);

            var res = action(writer);

            marsh.FinishMarshal(writer);

            return(res);
        }
Exemple #5
0
        /// <summary>
        /// Writes the request.
        /// </summary>
        private void WriteRequest(Action <BinaryWriter> writeAction, IBinaryStream stream)
        {
            if (writeAction != null)
            {
                var writer = _marsh.StartMarshal(stream);

                writeAction(writer);

                _marsh.FinishMarshal(writer);
            }
        }
        /// <summary>
        /// Writes method invocation result.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="marsh">Marshaller.</param>
        /// <param name="methodResult">Method result.</param>
        /// <param name="invocationError">Method invocation error.</param>
        public static void WriteInvocationResult(IBinaryStream stream, Marshaller marsh, object methodResult,
                                                 Exception invocationError)
        {
            Debug.Assert(stream != null);
            Debug.Assert(marsh != null);

            var writer = marsh.StartMarshal(stream);

            BinaryUtils.WriteInvocationResult(writer, invocationError == null, invocationError ?? methodResult);

            marsh.FinishMarshal(writer);
        }
Exemple #7
0
        /// <summary>
        /// Writes this instance to the stream.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="marsh">Marshaller.</param>
        public void Write(IBinaryStream stream, Marshaller marsh)
        {
            var writer = marsh.StartMarshal(stream);

            try
            {
                Marshal(writer);
            }
            finally
            {
                marsh.FinishMarshal(writer);
            }
        }
        /// <summary>
        /// Writes this instance to the stream.
        /// </summary>
        /// <param name="stream">Stream.</param>
        /// <param name="marsh">Marshaller.</param>
        public void Write(IBinaryStream stream, Marshaller marsh)
        {
            var writer = marsh.StartMarshal(stream);

            try
            {
                Marshal(writer);
            }
            finally
            {
                marsh.FinishMarshal(writer);
            }
        }
Exemple #9
0
        /// <summary>
        /// Writes the request.
        /// </summary>
        private void WriteRequest(Action <BinaryWriter> writeAction, IBinaryStream stream)
        {
            stream.WriteInt(_id);
            stream.WriteByte(0); // Flags (skipStore, etc).

            if (writeAction != null)
            {
                var writer = _marsh.StartMarshal(stream);

                writeAction(writer);

                _marsh.FinishMarshal(writer);
            }
        }
Exemple #10
0
        /// <summary>
        /// Does the out in op.
        /// </summary>
        private T DoOutInOp <T>(ClientOp opId, Action <BinaryWriter> writeAction,
                                Func <IBinaryStream, T> readFunc)
        {
            return(_socket.DoOutInOp(opId, stream =>
            {
                if (writeAction != null)
                {
                    var writer = _marsh.StartMarshal(stream);

                    writeAction(writer);

                    _marsh.FinishMarshal(writer);
                }
            }, readFunc));
        }
Exemple #11
0
        /// <summary>
        /// Does the out in op.
        /// </summary>
        private T DoOutInOp <T>(ClientOp opId, Action <BinaryWriter> writeAction,
                                Func <IBinaryStream, T> readFunc)
        {
            return(_ignite.Socket.DoOutInOp(opId, stream =>
            {
                stream.WriteInt(_id);
                stream.WriteByte(0);  // Flags (skipStore, etc).

                if (writeAction != null)
                {
                    var writer = _marsh.StartMarshal(stream);

                    writeAction(writer);

                    _marsh.FinishMarshal(writer);
                }
            }, readFunc));
        }
Exemple #12
0
        /// <summary>
        /// Writes the request.
        /// </summary>
        private void WriteRequest(Action <BinaryWriter> writeAction, IBinaryStream stream)
        {
            stream.WriteInt(_id);

            var writer = _marsh.StartMarshal(stream);

            if (_expiryPolicy != null)
            {
                stream.WriteByte((byte)ClientCacheRequestFlag.WithExpiryPolicy);
                ExpiryPolicySerializer.WritePolicy(writer, _expiryPolicy);
            }
            else
            {
                stream.WriteByte((byte)ClientCacheRequestFlag.None);  // Flags (skipStore, etc).
            }
            if (writeAction != null)
            {
                writeAction(writer);

                _marsh.FinishMarshal(writer);
            }
        }
Exemple #13
0
        /// <summary>
        /// Gets the unmanaged atomic reference.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="initialValue">The initial value.</param>
        /// <param name="create">Create flag.</param>
        /// <returns>Unmanaged atomic reference, or null.</returns>
        private IUnmanagedTarget GetAtomicReferenceUnmanaged <T>(string name, T initialValue, bool create)
        {
            IgniteArgumentCheck.NotNullOrEmpty(name, "name");

            // Do not allocate memory when default is not used.
            if (!create)
            {
                return(UU.ProcessorAtomicReference(_proc, name, 0, false));
            }

            using (var stream = IgniteManager.Memory.Allocate().GetStream())
            {
                var writer = Marshaller.StartMarshal(stream);

                writer.Write(initialValue);

                Marshaller.FinishMarshal(writer);

                var memPtr = stream.SynchronizeOutput();

                return(UU.ProcessorAtomicReference(_proc, name, memPtr, true));
            }
        }
Exemple #14
0
 /// <summary>
 /// Finish marshaling.
 /// </summary>
 /// <param name="writer">Writer.</param>
 internal void FinishMarshal(BinaryWriter writer)
 {
     _marsh.FinishMarshal(writer);
 }
Exemple #15
0
 /// <summary>
 /// Finish marshaling.
 /// </summary>
 /// <param name="writer">Writer.</param>
 private void FinishMarshal(BinaryWriter writer)
 {
     _marsh.FinishMarshal(writer);
 }