当前位置: 首页 > news >正文

做网站超链接网站流量怎样挣钱

做网站超链接,网站流量怎样挣钱,选择网站开发公司的标准,网络违法犯罪举报网站介绍 以一个简易版的数据库连接池的实现来说明一下 连接池的connection以队列来管理 getConnection的时候#xff0c;如果队列中connection个数小于50#xff0c;且暂时无可用的connection#xff08;个数为0或者peek看下头部需要先出那个元素还处于不可用状态#xff09;…介绍 以一个简易版的数据库连接池的实现来说明一下 连接池的connection以队列来管理 getConnection的时候如果队列中connection个数小于50且暂时无可用的connection个数为0或者peek看下头部需要先出那个元素还处于不可用状态就新建连接并建立连接开始一直新建到50个connection就是_currentPoolSize 50 如果队列中connection个数大于等于50且暂时无可用的connection个数为0或者peek看下头部需要先出那个元素还处于不可用状态就等着Monitor.Wait(_connectionPoolQueueLock) returnConnection的时候使用Monitor.Pulse(_connectionPoolQueueLock) 随机通知一个wait的线程可以继续getConnection了 using System; using System.Collections.Generic; using System.Data; using System.Threading; using Mono.Data.Sqlite;namespace demo.unity.sqlite {public class SQLiteConnectionManager{private QueueTupleSqliteConnection, DateTime _connectionPoolQueue;private object _connectionPoolQueueLock new object();private const int maxPoolSize 50;private volatile bool _disposed;private int _currentPoolSize;private readonly System.Timers.Timer _cleanupTimer new System.Timers.Timer(10 * 60 * 1000);public SQLiteConnectionManager(){_connectionPoolQueue new QueueTupleSqliteConnection, DateTime(maxPoolSize);_cleanupTimer.Elapsed _cleanupTimerElapsed;_cleanupTimer.AutoReset true;_cleanupTimer.Start();}private void _cleanupTimerElapsed(object sender, System.Timers.ElapsedEventArgs e){lock (_connectionPoolQueueLock){while (_connectionPoolQueue.Count 0 (DateTime.UtcNow - _connectionPoolQueue.Peek().Item2).TotalMinutes 15){var tup _connectionPoolQueue.Dequeue();tup.Item1.Dispose();_currentPoolSize--;}}}private SqliteConnection _createNewConnection(SqliteConnectionStringBuilder builder){var connection new SqliteConnection(builder.ConnectionString);connection.Open();return connection;}public SqliteConnection getConnection(SqliteConnectionStringBuilder builder){lock (_connectionPoolQueueLock){// count 0 or queue.peek no use connectionwhile (_connectionPoolQueue.Count 0 || _connectionPoolQueue.Peek().Item1.State ! ConnectionState.Open){if (_disposed){throw new ObjectDisposedException(The DB connection pool is is already disposed);}if (_currentPoolSize maxPoolSize){// create and open connectionvar connection _createNewConnection(builder);_connectionPoolQueue.Enqueue( new TupleSqliteConnection, DateTime(connection, DateTime.UtcNow));_currentPoolSize;}else{Monitor.Wait(_connectionPoolQueueLock);}}return _connectionPoolQueue.Dequeue().Item1;}}public void returnConnection(SqliteConnection connection){if (connection null){return;}lock (_connectionPoolQueueLock){_connectionPoolQueue.Enqueue(new TupleSqliteConnection, DateTime(connection, DateTime.UtcNow));Monitor.Pulse(_connectionPoolQueueLock);}}public void dispose(){lock (_connectionPoolQueueLock){_disposed true;while (_connectionPoolQueue.Count 0){var tup _connectionPoolQueue.Dequeue();tup.Item1?.Dispose();_currentPoolSize--;}// wake up any waiting threadsMonitor.PulseAll(_connectionPoolQueueLock);}_cleanupTimer.Stop();_cleanupTimer.Dispose();}} }
http://www.w-s-a.com/news/874925/

相关文章:

  • 网站建设玖金手指排名11专业建站公司建站系统
  • 全球排名前十网站百度网站官网网址
  • 商家在携程旅游网站怎样做宣传做网站公司苏州
  • 芜湖做网站都有哪些广州音乐制作公司
  • 青岛好的网站制作推广注册公司流程步骤
  • 怎么制作营销网站模板wordpress苗木模板
  • 手机网站样例wordpress 排序
  • 济南网站建设手机网站开发人员需要去做原型吗
  • 动易网站模板下载微信支付 wordpress
  • 学校建设外文网站情况阿里云 建设网站怎么样
  • 网站建设与网页设计制作深圳网站建设首选上榜网络
  • 网站浏览成交指标计算机应用是做什么的
  • 企业网站建设的要求wordpress 404页面模板
  • 公司怎么注册官方网站wordpress花园网站
  • 一般网站的建设步骤有哪些企业网站建设应该注意什么事项问题
  • 枣庄市建设局网站建设工程合同交底的内容包括
  • 全国十大跨境电商排名seo优化入门教程
  • 福安网站开发网站内容建设要求age06
  • 网站开发制作公司罗湖在线
  • 做网站银川潍坊网络科技有限公司
  • 南宁企业网站建站模板盐田高端网站建设
  • 深圳市建设局网站张局北京档案馆网站建设
  • 运动健身型网站开发网站备案掉了什么原因
  • 网站开发的前后端是什么注册网站多少钱一年
  • 彩票网站建设需要什么网站未备案被阻断怎么做
  • wordpress 版权声明网站优化排名哪家性价比高
  • dedecms网站关键词外包做网站平台 一分钟
  • 酒网站建设游戏分类网站怎么做
  • 仿牌网站安全北京大良网站建设
  • ps中怎样做网站轮播图片吉林省网站建设公司