public static void ReturnWriter(DarkRiftWriter writer)
        {
            if (!initialized)
            {
                ThreadInitialize();
            }

#if DEBUG
            ObjectCacheTestHelper.DarkRiftWriterWasReturned();
#endif
            writerPool.ReturnInstance(writer);
        }
Exemple #2
0
        /// <summary>
        ///     Creates a new DarkRift writer with an initial capacity and specified encoding.
        /// </summary>
        /// <param name="initialCapacity">The initial capacity for the backing array.</param>
        /// <param name="encoding">The encoding to serialize strings and characters using.</param>
        public static DarkRiftWriter Create(int initialCapacity, Encoding encoding)
        {
            DarkRiftWriter writer = ObjectCache.GetWriter();

            writer.isCurrentlyLoungingInAPool = false;

            writer.buffer = MessageBuffer.Create(initialCapacity);

            writer.Position = 0;
            writer.Encoding = encoding;
            return(writer);
        }
Exemple #3
0
 /// <summary>
 ///     Creates a new SerializeEvent.
 /// </summary>
 /// <param name="writer">The writer to serialize to.</param>
 public SerializeEvent(DarkRiftWriter writer)
 {
     Writer = writer;
 }