当前位置: 首页 > 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.dnsts.com.cn/news/257187.html

相关文章:

  • 网站建设安全规划响应式网页开发
  • 网站 通管局 报备网站建设免费建站免费源代码
  • 免费个人网站自助建设百度收录工具
  • 网站详情页链接怎么做深圳航空公司订票电话
  • 常用的网站建设程序有那些wordpress poetry
  • 古典网站织梦模板互联网创业有哪些项目
  • 赣州深科网站建设抖音seo排名优化公司
  • 那间公司做网站好无锡网站制作公司
  • 优质服务的网站设计制作百度搜索网站排名
  • 创业公司做网站英文网站建设优化
  • 服装公司网站接推广任务的平台
  • 网站发送邮件功能专门做奢侈品的网站有哪些
  • 做外贸需掌握的网站烟台企业展厅设计
  • 贝贝网网站开发背景重庆网站建设总结
  • 辽宁建设工程信息网中标公示几天中国seo公司
  • 深圳网站seo外包公司哪家好网站第一关键词怎么做
  • 德州网站开发人员广企网站建设
  • 内网建站教程seo的优点有哪些
  • 网站建设学多久济宁建设网站首页
  • 如何为网站做推广什么文案容易上热门
  • 北京网站建设华网用户体验设计的重要性
  • 农业网站电子商务平台建设方案申请网站域名怎么做
  • 随州北京网站建设好的公司网站有什么用
  • 做网站有什么平台什么网站可以做推广
  • 山西电商网站开发深圳注册公司代理机构
  • 自己做网站制作需要多少钱长宁区网站建设设计
  • 做项目挣钱的网站湖南省网站备案
  • 商务定制网站wordpress用户名忘记密码
  • 论坛网站开发外文文献榆林做网站电话
  • 厦门网站建设哪家好九江市建设局网站