예제 #1
0
        public byte[] Compile(out int length)
        {
            if (mCompiledBuffer == null)
            {
                if ((mState & EPacketState.Accessed) == 0)
                {
                    mState |= EPacketState.Accessed;
                }
                else
                {
                    if ((mState & EPacketState.Warned) == 0)
                    {
                        mState |= EPacketState.Warned;

                        try {
                            using (StreamWriter op = new StreamWriter("net_opt.log", true)) {
                                op.WriteLine("Redundant compile for packet {0}, use Acquire() and Release()", this.GetType());
                                op.WriteLine(new System.Diagnostics.StackTrace());
                            }
                        } catch { }
                    }

                    mCompiledBuffer = new byte[0];
                    mCompiledLength = 0;

                    length = mCompiledLength;
                    return(mCompiledBuffer);
                }

                InternalCompile();
            }

            length = mCompiledLength;
            return(mCompiledBuffer);
        }
예제 #2
0
        private void Free()
        {
            if (mCompiledBuffer == null)
            {
                return;
            }

            if ((mState & EPacketState.Buffered) != 0)
            {
                mBuffers.ReleaseBuffer(mCompiledBuffer);
            }

            mState &= ~(EPacketState.Static | EPacketState.Acquired | EPacketState.Buffered);

            mCompiledBuffer = null;
        }
예제 #3
0
파일: Packet.cs 프로젝트: GodLesZ/svn-dump
		public void Acquire() {
			mState |= EPacketState.Acquired;
		}
예제 #4
0
파일: Packet.cs 프로젝트: GodLesZ/svn-dump
		public void SetStatic() {
			mState |= EPacketState.Static | EPacketState.Acquired;
		}
예제 #5
0
파일: Packet.cs 프로젝트: GodLesZ/svn-dump
		public byte[] Compile(out int length) {
			if (mCompiledBuffer == null) {
				if ((mState & EPacketState.Accessed) == 0) {
					mState |= EPacketState.Accessed;
				} else {
					if ((mState & EPacketState.Warned) == 0) {
						mState |= EPacketState.Warned;

						try {
							using (var op = new StreamWriter("net_opt.log", true)) {
								op.WriteLine("Redundant compile for packet {0}, use Acquire() and Release()", GetType());
								op.WriteLine(new System.Diagnostics.StackTrace());
							}
						} catch { }
					}

					mCompiledBuffer = new byte[0];
					mCompiledLength = 0;

					length = mCompiledLength;
					return mCompiledBuffer;
				}

				InternalCompile();
			}

			length = mCompiledLength;
			return mCompiledBuffer;
		}
예제 #6
0
파일: Packet.cs 프로젝트: GodLesZ/svn-dump
		private void Free() {
			if (mCompiledBuffer == null)
				return;

			if ((mState & EPacketState.Buffered) != 0)
				mBuffers.ReleaseBuffer(mCompiledBuffer);

			mState &= ~(EPacketState.Static | EPacketState.Acquired | EPacketState.Buffered);

			mCompiledBuffer = null;
		}
예제 #7
0
 public void Acquire()
 {
     mState |= EPacketState.Acquired;
 }
예제 #8
0
 public void SetStatic()
 {
     mState |= EPacketState.Static | EPacketState.Acquired;
 }