Ejemplo n.º 1
0
 public DruidDbConnection(DruidConnectionHolder holder)
 {
     DbConnection        = holder.Connection;
     Holder              = holder;
     OwnerThread         = Thread.CurrentThread;
     ConnectedTimeMillis = SbUtil.CurrentTimeMillis();
 }
Ejemplo n.º 2
0
 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();
        }
Ejemplo n.º 4
0
        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);
            }
        }