Fan.Sys.Sys.safe C# (CSharp) Method

safe() public static method

public static safe ( object obj ) : object
obj object
return object
        public static object safe(object obj)
        {
            if (obj == null) return null;
              if (FanObj.isImmutable(obj)) return obj;
              Buf buf = new MemBuf(512);
              buf.writeObj(obj);
              buf.flip();
              return buf.readObj();
        }

Usage Example

Example #1
0
        //////////////////////////////////////////////////////////////////////////
        // Implementation
        //////////////////////////////////////////////////////////////////////////

        private Future _send(object msg, Duration dur, Future whenDone)
        {
            // ensure immutable or safe copy
            msg = Sys.safe(msg);

            // don't deliver new messages to a stopped pool
            if (m_pool.isStopped())
            {
                throw Err.make("ActorPool is stopped").val;
            }

            // get the future instance to manage this message's lifecycle
            Future f = new Future(msg);

            // either enqueue immediately or schedule with pool
            if (dur != null)
            {
                m_pool.schedule(this, dur, f);
            }
            else if (whenDone != null)
            {
                whenDone.sendWhenDone(this, f);
            }
            else
            {
                f = _enqueue(f, true);
            }

            return(f);
        }
All Usage Examples Of Fan.Sys.Sys::safe