unixTimestamp() public static method

public static unixTimestamp ( System time ) : int
time System
return int
Ejemplo n.º 1
0
 /**
  * 将接收到的Rpc消息推入处理队列,等待线程读取
  *
  */
 internal RpcCommunicator enqueueMessage(int sequence, RpcMessage m)
 {
     lock (_cachedMsgList) {
         m.issuetime = Utility.unixTimestamp(DateTime.Now);
         _cachedMsgList.Add(sequence, m);
     }
     return(this);
 }
Ejemplo n.º 2
0
        protected void _timerCheckHealth(object source, System.Timers.ElapsedEventArgs e)
        {
            //RpcCommunicator.instance().logger.debug("Communicator:: health checking..");
            List <RpcMessage> removeList = new List <RpcMessage>();

            lock (_cachedMsgList){
                long       cursec         = Utility.unixTimestamp(DateTime.Now);
                List <int> deprecatedlist = new List <int>();
                foreach (KeyValuePair <int, RpcMessage> kv in _cachedMsgList)
                {
                    if ((cursec - kv.Value.issuetime) * 1000 > _settings.callwait)
                    {
                        deprecatedlist.Add(kv.Key);
                    }
                }
                foreach (int seq in deprecatedlist)
                {
                    removeList.Add(_cachedMsgList[seq]);
                    _cachedMsgList.Remove(seq);
                    RpcCommunicator.instance().logger.error(String.Format("message({0}) be dropped for timeout", seq));
                }
            }
            //
            foreach (RpcMessage message in removeList)
            {
                if (message.async.promise == null)
                {
                    message.async.onError(RpcException.RPCERROR_TIMEOUT);
                }
                else
                {
                    RpcAsyncContext ctx = new RpcAsyncContext();
                    ctx.promise   = message.async.promise;
                    ctx.exception = new RpcException(RpcException.RPCERROR_TIMEOUT);
                    message.async.promise.onError(ctx);
                }
            }
        }