public DruidDbConnection(DruidConnectionHolder holder) { DbConnection = holder.Connection; Holder = holder; OwnerThread = Thread.CurrentThread; ConnectedTimeMillis = SbUtil.CurrentTimeMillis(); }
public void SetConnectedTimeNano() { if (ConnectedTimeNano <= 0) { ConnectedTimeNano = SbUtil.NanoTime(); } }
public DruidConnectionHolder(DruidDataSource dataSource, IDbConnection dbConnection, long connectNanoSpan) { Trace.Assert(dataSource != null, "dataSource can not be null"); this.DataSource = dataSource; this.Connection = dbConnection; this.CreateNanoSpan = connectNanoSpan; this.ConnectTimeMillis = SbUtil.CurrentTimeMillis(); this.LastActiveTimeMillis = ConnectTimeMillis; this.ConnectionId = dataSource.CreateConnectionId(); }
public static void ParkUntil(long deadline) { if (deadline > 0L) { var time = (int)(deadline - SbUtil.CurrentTimeMillis()) / 1000; var id = Thread.CurrentThread.ManagedThreadId; var b_exist = dic.TryGetValue(id, out var lockobj); if (b_exist) { lockobj.Wait(time); return; } lockobj = new SemaphoreSlim(0); dic.TryAdd(id, lockobj); lockobj.Wait(time); } }