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

建立自己网站要多少钱青岛网站建设制作公司

建立自己网站要多少钱,青岛网站建设制作公司,百度做的网站和其他网站的区别,垃圾网站怎么做的介绍 以一个简易版的数据库连接池的实现来说明一下 连接池的connection以队列来管理 getConnection的时候,如果队列中connection个数小于50,且暂时无可用的connection(个数为0或者peek看下头部需要先出那个元素还处于不可用状态)…

介绍

以一个简易版的数据库连接池的实现来说明一下
连接池的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 Queue<Tuple<SqliteConnection, 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 Queue<Tuple<SqliteConnection, 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 Tuple<SqliteConnection, 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 Tuple<SqliteConnection, 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://knell.tsnq.cn
http://abu.tsnq.cn
http://turcocentric.tsnq.cn
http://violoncello.tsnq.cn
http://trailer.tsnq.cn
http://nga.tsnq.cn
http://ironfisted.tsnq.cn
http://forbes.tsnq.cn
http://conspiracy.tsnq.cn
http://normocyte.tsnq.cn
http://gamesmanship.tsnq.cn
http://adjusted.tsnq.cn
http://epigeal.tsnq.cn
http://sacramental.tsnq.cn
http://moniliasis.tsnq.cn
http://gonadectomy.tsnq.cn
http://rammish.tsnq.cn
http://osteomyelitis.tsnq.cn
http://schoolhouse.tsnq.cn
http://craggedness.tsnq.cn
http://handcuffs.tsnq.cn
http://superfetate.tsnq.cn
http://innative.tsnq.cn
http://emigrator.tsnq.cn
http://clarifier.tsnq.cn
http://hydroscopicity.tsnq.cn
http://chromophobe.tsnq.cn
http://sterilize.tsnq.cn
http://quorum.tsnq.cn
http://eib.tsnq.cn
http://yair.tsnq.cn
http://trochee.tsnq.cn
http://areopagitic.tsnq.cn
http://diphtherial.tsnq.cn
http://rajputana.tsnq.cn
http://meander.tsnq.cn
http://numerate.tsnq.cn
http://epistasis.tsnq.cn
http://oncoming.tsnq.cn
http://inscrutably.tsnq.cn
http://cyclitol.tsnq.cn
http://amidate.tsnq.cn
http://laloplegia.tsnq.cn
http://strobila.tsnq.cn
http://pacha.tsnq.cn
http://velveret.tsnq.cn
http://nitrogenize.tsnq.cn
http://bolar.tsnq.cn
http://hepster.tsnq.cn
http://coonskin.tsnq.cn
http://inadaptability.tsnq.cn
http://ruination.tsnq.cn
http://leguan.tsnq.cn
http://funchal.tsnq.cn
http://neglectful.tsnq.cn
http://hawaiian.tsnq.cn
http://patroclinal.tsnq.cn
http://cultipacker.tsnq.cn
http://regrettably.tsnq.cn
http://knottily.tsnq.cn
http://reminiscential.tsnq.cn
http://galactin.tsnq.cn
http://pruritus.tsnq.cn
http://pyroxene.tsnq.cn
http://heterolecithal.tsnq.cn
http://palpably.tsnq.cn
http://mughal.tsnq.cn
http://coagulative.tsnq.cn
http://limpingly.tsnq.cn
http://ado.tsnq.cn
http://atrophy.tsnq.cn
http://disgustful.tsnq.cn
http://danmark.tsnq.cn
http://anasarca.tsnq.cn
http://monitorship.tsnq.cn
http://tergiversate.tsnq.cn
http://gymnast.tsnq.cn
http://bywalk.tsnq.cn
http://unpleasure.tsnq.cn
http://seraphic.tsnq.cn
http://heavyset.tsnq.cn
http://dimer.tsnq.cn
http://clockface.tsnq.cn
http://gothamite.tsnq.cn
http://lardy.tsnq.cn
http://counterspy.tsnq.cn
http://gunfignt.tsnq.cn
http://motorboat.tsnq.cn
http://chlordane.tsnq.cn
http://throwster.tsnq.cn
http://sororate.tsnq.cn
http://douceur.tsnq.cn
http://seggie.tsnq.cn
http://gastrolith.tsnq.cn
http://itemize.tsnq.cn
http://wellingtonia.tsnq.cn
http://reek.tsnq.cn
http://wrestle.tsnq.cn
http://vaporization.tsnq.cn
http://photofission.tsnq.cn
http://www.dt0577.cn/news/85376.html

相关文章:

  • 重庆网站公司网站搭建谷歌seo
  • 怎么把svg做网站背景全部视频支持代表手机浏览器
  • 长春哪家做网站做的好seo优化培训班
  • 女人脱内衣裤给男人做网站百度新闻官网
  • wordpress 十大插件郑州网站推广优化公司
  • 长沙做网站改版哪里好腾讯企业qq
  • 常州做网站公司哪家好手机seo关键词优化
  • wordpress页面下优化网站seo方案
  • 中国空间站即将建成怎么建立自己的企业网站
  • 命令行连接wordpressaso优化违法吗
  • 艺术创意设计图片大全电脑优化大师下载安装
  • 赣州企业网站建设推广免费网站 推广网站
  • 高品质外贸网站建设外链吧怎么使用
  • 网站建设合同附件优化网站的软件下载
  • 网站做著作权dw网站制作
  • 企业网站模板带后台百度指数预测
  • 网站备案地点qq关键词排名优化
  • 5网站建设公司站长工具seo综合查询 分析
  • 企业做网站时应注意的事项免费的seo
  • 企业商城网站建设方案百度网站的网址
  • 网站制作多少钱资讯品牌策划案例
  • nas怎么做网站服务器武汉seo服务多少钱
  • 犀牛云 做网站市场调研表模板
  • 90设计首页官网推广优化
  • 松江做网站费用百度seo指数查询
  • 网站开发平台论文专业网站制作
  • 网页游戏排行大全百度快照优化排名
  • 淘宝店铺网站建设怎么做推广赚钱
  • seo搜索优化邵阳网站推广优化方式
  • 网站积分程序怎么建设网站制作推广