时隔这么久 才再一次的回归正题继续讲解游戏服务器开发。

开始讲解前有一个问题需要修正。之前讲的线程和定时器线程的时候是分开的。

但是真正地图线程与之前的线程模型是有区别的。

  1. 为什么会有区别呢?一个地图肯定有执行线程,但是每一个地图都有不同的时间任务。比如检测玩家身上的buffer,检测玩家的状态值。这种情况下如何处理呢?很明显就需要定时器线程。

我的处理方式是创建一个线程的时候根据需求创建对应的 timerthread

直接上代码其他不BB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Sz.ThreadPool
  9. {
  10. /// <summary>
  11. /// 线程模型
  12. /// </summary>
  13. public class ThreadModel
  14. {
  15. /// <summary>
  16. ///
  17. /// </summary>
  18. public bool IsStop = false;
  19. /// <summary>
  20. /// ID
  21. /// </summary>
  22. public int ID { get; private set; }
  23. /// <summary>
  24. /// 已分配的自定义线程静态ID
  25. /// </summary>
  26. public static int StaticID { get; private set; }
  27.  
  28. string Name;
  29.  
  30. /// <summary>
  31. /// 初始化线程模型,
  32. /// </summary>
  33. /// <param name="name"></param>
  34. public ThreadModel(String name)
  35. : )
  36. {
  37.  
  38. }
  39.  
  40. /// <summary>
  41. /// 初始化线程模型
  42. /// </summary>
  43. /// <param name="name">线程名称</param>
  44. /// <param name="count">线程数量</param>
  45. public ThreadModel(String name, Int32 count)
  46. {
  47. lock (typeof(ThreadModel))
  48. {
  49. StaticID++;
  50. ID = StaticID;
  51. }
  52. this.Name = name;
  53. )
  54. {
  55. System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
  56. thread.Name = "< " + name + "线程 >";
  57. thread.Start();
  58. Logger.Info("初始化 " + thread.Name);
  59. }
  60. else
  61. {
  62. ; i < count; i++)
  63. {
  64. System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
  65. thread.Name = ) + "线程 >";
  66. thread.Start();
  67. Logger.Info("初始化 " + thread.Name);
  68. }
  69. }
  70. }
  71.  
  72. System.Threading.Thread threadTimer = null;
  73.  
  74. /// <summary>
  75. /// 任务队列
  76. /// </summary>
  77. protected List<TaskModel> taskQueue = new List<TaskModel>();
  78. /// <summary>
  79. /// 任务队列
  80. /// </summary>
  81. private List<TimerTask> timerTaskQueue = new List<TimerTask>();
  82.  
  83. /// <summary>
  84. /// 加入任务
  85. /// </summary>
  86. /// <param name="t"></param>
  87. public virtual void AddTask(TaskModel t)
  88. {
  89. lock (taskQueue)
  90. {
  91. taskQueue.Add(t);
  92. }
  93. //防止线程正在阻塞时添加进入了新任务
  94. are.Set();
  95. }
  96.  
  97. /// <summary>
  98. /// 加入任务
  99. /// </summary>
  100. /// <param name="t"></param>
  101. public void AddTimerTask(TimerTask t)
  102. {
  103. t.RunAttribute["lastactiontime"] = SzExtensions.CurrentTimeMillis();
  104. if (t.IsStartAction)
  105. {
  106. AddTask(t);
  107. }
  108. lock (timerTaskQueue)
  109. {
  110. if (threadTimer == null)
  111. {
  112. threadTimer = new System.Threading.Thread(new System.Threading.ThreadStart(TimerRun));
  113. threadTimer.Name = "< " + this.Name + " - Timer线程 >";
  114. threadTimer.Start();
  115. Logger.Info("初始化 " + threadTimer.Name);
  116. }
  117. timerTaskQueue.Add(t);
  118. }
  119. timerAre.Set();
  120. }
  121.  
  122. /// <summary>
  123. /// 通知一个或多个正在等待的线程已发生事件
  124. /// </summary>
  125. protected ManualResetEvent are = new ManualResetEvent(false);
  126.  
  127. /// <summary>
  128. /// 通知一个或多个正在等待的线程已发生事件
  129. /// </summary>
  130. protected ManualResetEvent timerAre = new ManualResetEvent(true);
  131.  
  132. /// <summary>
  133. /// 线程处理器
  134. /// </summary>
  135. protected virtual void Run()
  136. {
  137. while (!this.IsStop)
  138. {
  139. ))
  140. {
  141. TaskModel task = null;
  142. lock (taskQueue)
  143. {
  144. )
  145. {
  146. task = taskQueue[];
  147. taskQueue.RemoveAt();
  148. }
  149. else { break; }
  150. }
  151.  
  152. /* 执行任务 */
  153. //r.setSubmitTimeL();
  154. long submitTime = SzExtensions.CurrentTimeMillis();
  155. try
  156. {
  157. task.Run();
  158. }
  159. catch (Exception e)
  160. {
  161. Logger.Error(Thread.CurrentThread.Name + " 执行任务:" + task.ToString() + " 遇到错误", e);
  162. continue;
  163. }
  164. long timeL1 = SzExtensions.CurrentTimeMillis() - submitTime;
  165. long timeL2 = SzExtensions.CurrentTimeMillis() - task.GetSubmitTime();
  166. ) { }
  167. else if (timeL1 <= 200L) { Logger.Debug(Thread.CurrentThread.Name + " 完成了任务:" + task.ToString() + " 执行耗时:" + timeL1 + " 提交耗时:" + timeL2); }
  168. else if (timeL1 <= 1000L) { Logger.Info(Thread.CurrentThread.Name + " 长时间执行 完成任务:" + task.ToString() + " “考虑”任务脚本逻辑 耗时:" + timeL1 + " 提交耗时:" + timeL2); }
  169. else if (timeL1 <= 4000L) { Logger.Error(Thread.CurrentThread.Name + " 超长时间执行完成 任务:" + task.ToString() + " “检查”任务脚本逻辑 耗时:" + timeL1 + " 提交耗时:" + timeL2); }
  170. else
  171. {
  172. Logger.Error(Thread.CurrentThread.Name + " 超长时间执行完成 任务:" + task.ToString() + " “考虑是否应该删除”任务脚本 耗时:" + timeL1 + " 提交耗时:" + timeL2);
  173. }
  174. task = null;
  175. }
  176. are.Reset();
  177. //队列为空等待200毫秒继续
  178. are.WaitOne();
  179. }
  180. Console.WriteLine(DateTime.Now.NowString() + " " + Thread.CurrentThread.Name + " Destroying");
  181. }
  182.  
  183. /// <summary>
  184. /// 定时器线程处理器
  185. /// </summary>
  186. protected virtual void TimerRun()
  187. {
  188. ///无限循环执行函数器
  189. while (!this.IsStop)
  190. {
  191. )
  192. {
  193. IEnumerable<TimerTask> collections = null;
  194. lock (timerTaskQueue)
  195. {
  196. collections = new List<TimerTask>(timerTaskQueue);
  197. }
  198. foreach (TimerTask timerEvent in collections)
  199. {
  200. int execCount = timerEvent.RunAttribute.GetintValue("Execcount");
  201. long lastTime = timerEvent.RunAttribute.GetlongValue("LastExecTime");
  202. long nowTime = SzExtensions.CurrentTimeMillis();
  203. if (nowTime > timerEvent.StartTime //是否满足开始时间
  204. && (nowTime - timerEvent.GetSubmitTime() > timerEvent.IntervalTime)//提交以后是否满足了间隔时间
  205. && (timerEvent.EndTime <= || nowTime < timerEvent.EndTime) //判断结束时间
  206. && (nowTime - lastTime >= timerEvent.IntervalTime))//判断上次执行到目前是否满足间隔时间
  207. {
  208. //提交执行
  209. this.AddTask(timerEvent);
  210. //记录
  211. execCount++;
  212. timerEvent.RunAttribute["Execcount"] = execCount;
  213. timerEvent.RunAttribute["LastExecTime"] = nowTime;
  214. }
  215. nowTime = SzExtensions.CurrentTimeMillis();
  216. //判断删除条件
  217. && nowTime < timerEvent.EndTime)
  218. || (timerEvent.ActionCount > && timerEvent.ActionCount <= execCount))
  219. {
  220. timerTaskQueue.Remove(timerEvent);
  221. }
  222. }
  223. timerAre.Reset();
  224. timerAre.WaitOne();
  225. }
  226. else
  227. {
  228. timerAre.Reset();
  229. //队列为空等待200毫秒继续
  230. timerAre.WaitOne();
  231. }
  232. }
  233. Console.WriteLine(DateTime.Now.NowString() + "Thread:<" + Thread.CurrentThread.Name + "> Destroying");
  234. }
  235. }
  236. }

当我线程里面第一次添加定时器任务的时候加触发定时器线程的初始化。

先看看效果

地图运作方式怎么样的呢?

来一张图片看看

在正常情况下一个地图需要这些事情。然后大部分事情是需要定时器任务处理的,只有客户端交互通信是不需要定时器任务处理。

封装地图信息类

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Sz.MMO.GameServer.IMapScripts;
  7. using Sz.MMO.GameServer.TimerMap;
  8. using Sz.MMO.GameServer.TimerMonster;
  9.  
  10. /**
  11. *
  12. * @author 失足程序员
  13. * @Blog http://www.cnblogs.com/ty408/
  14. * @mail 492794628@qq.com
  15. * @phone 13882122019
  16. *
  17. */
  18. namespace Sz.MMO.GameServer.Structs.Map
  19. {
  20. /// <summary>
  21. ///
  22. /// </summary>
  23. public class MapInfo<TPlayer, TNpc, TMonster, TDropGoods> : IEnterMapMonsterScript, IEnterMapNpcScript, IEnterMapPlayerScript, IEnterMapDropGoodsScript
  24. {
  25. /// <summary>
  26. /// 为跨服设计的服务器id
  27. /// </summary>
  28. public int ServerID { get; set; }
  29. /// <summary>
  30. /// 地图模板id
  31. /// </summary>
  32. public int MapModelID { get; set; }
  33. /// <summary>
  34. /// 地图id
  35. /// </summary>
  36. public long MapID { get; set; }
  37.  
  38. /// <summary>
  39. /// 地图分线处理
  40. /// </summary>
  41. Dictionary<int, MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods>> mapLineInfos = new Dictionary<int, MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods>>();
  42.  
  43. )
  44. {
  45.  
  46. this.MapID = SzExtensions.GetId();
  47. this.MapModelID = mapModelId;
  48. Logger.Debug("开始初始化地图: " + name + " 地图ID:" + MapID);
  49.  
  50. ; i <= lineCount; i++)
  51. {
  52. MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods> lineInfo = new MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods>(name + "-" + i + "线");
  53.  
  54. mapLineInfos[i] = lineInfo;
  55. }
  56. Logger.Debug("初始化地图: " + name + " 地图ID:" + MapID + " 结束");
  57. }
  58.  
  59. }
  60.  
  61. #region 地图分线 class MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods> : IEnterMapMonsterScript, IEnterMapNpcScript, IEnterMapPlayerScript, IEnterMapDropGoodsScript
  62. /// <summary>
  63. /// 地图分线
  64. /// </summary>
  65. /// <typeparam name="TPlayer"></typeparam>
  66. /// <typeparam name="TNpc"></typeparam>
  67. /// <typeparam name="TMonster"></typeparam>
  68. /// <typeparam name="TDropGoods"></typeparam>
  69. class MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods> : IEnterMapMonsterScript, IEnterMapNpcScript, IEnterMapPlayerScript, IEnterMapDropGoodsScript
  70. {
  71. public MapThread MapServer { get; set; }
  72.  
  73. public int ServerID { get; set; }
  74.  
  75. public int LineID { get; set; }
  76.  
  77. public int MapModelID { get; set; }
  78.  
  79. public long MapID { get; set; }
  80.  
  81. public MapLineInfo(string name)
  82. {
  83. Players = new List<TPlayer>();
  84. Monsters = new List<TMonster>();
  85. Npcs = new List<TNpc>();
  86. DropGoodss = new List<TDropGoods>();
  87. MapServer = new Structs.Map.MapThread(name);
  88. }
  89.  
  90. /// <summary>
  91. /// 地图玩家
  92. /// </summary>
  93. public List<TPlayer> Players { get; set; }
  94.  
  95. /// <summary>
  96. /// 地图npc
  97. /// </summary>
  98. public List<TNpc> Npcs { get; set; }
  99.  
  100. /// <summary>
  101. /// 地图怪物
  102. /// </summary>
  103. public List<TMonster> Monsters { get; set; }
  104.  
  105. /// <summary>
  106. /// 地图掉落物
  107. /// </summary>
  108. public List<TDropGoods> DropGoodss { get; set; }
  109. }
  110. #endregion
  111. }
  1. Structs.Map.MapInfo<Player, Npc, Monster, Drop> map = , );

这样就创建了一张地图。我们创建的新手村有两条线。也就是两个线程

这样只是创建地图容器和地图线程而已。

如何添加各个定时器呢?

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Sz.MMO.GameServer.IMapScripts;
  7.  
  8. /**
  9. *
  10. * @author 失足程序员
  11. * @Blog http://www.cnblogs.com/ty408/
  12. * @mail 492794628@qq.com
  13. * @phone 13882122019
  14. *
  15. */
  16. namespace Sz.MMO.GameServer.TimerMap
  17. {
  18. /// <summary>
  19. ///
  20. /// </summary>
  21. public class MapHeartTimer : ThreadPool.TimerTask
  22. {
  23.  
  24. int serverID, lineID, mapModelID;
  25. long mapID;
  26.  
  27. /// <summary>
  28. /// 指定1秒执行一次
  29. /// </summary>
  30. public MapHeartTimer(int serverID, int lineID, long mapID, int mapModelID)
  31. : * )
  32. {
  33. this.serverID = serverID;
  34. this.lineID = lineID;
  35. this.mapID = mapID;
  36. this.mapModelID = mapModelID;
  37. }
  38.  
  39. /// <summary>
  40. ///
  41. /// </summary>
  42. public override void Run()
  43. {
  44.  
  45. Logger.Debug("我是地图心跳检查器 执行线程:" + System.Threading.Thread.CurrentThread.Name);
  46. Logger.Debug("我是地图心跳检查器 检查玩家是否需要复活,回血,状态");
  47. //var scripts = Sz.ScriptPool.ScriptManager.Instance.GetInstances<IMapHeartTimerScript>();
  48. //foreach (var item in scripts)
  49. //{
  50. // item.Run(serverID, lineID, mapID, mapModelID);
  51. //}
  52. }
  53.  
  54. }
  55. }
  56.  
  57. using System;
  58. using System.Collections.Generic;
  59. using System.Linq;
  60. using System.Text;
  61. using System.Threading.Tasks;
  62. using Sz.MMO.GameServer.IMonsterScripts;
  63.  
  64. /**
  65. *
  66. * @author 失足程序员
  67. * @Blog http://www.cnblogs.com/ty408/
  68. * @mail 492794628@qq.com
  69. * @phone 13882122019
  70. *
  71. */
  72. namespace Sz.MMO.GameServer.TimerMonster
  73. {
  74. /// <summary>
  75. ///
  76. /// </summary>
  77. public class MonsterHeartTimer: ThreadPool.TimerTask
  78. {
  79.  
  80. int serverID, lineID, mapModelID;
  81. long mapID;
  82.  
  83. /// <summary>
  84. /// 指定1秒执行一次
  85. /// </summary>
  86. public MonsterHeartTimer(int serverID, int lineID, long mapID, int mapModelID)
  87. : * )
  88. {
  89. this.serverID = serverID;
  90. this.lineID = lineID;
  91. this.mapID = mapID;
  92. this.mapModelID = mapModelID;
  93. }
  94.  
  95. /// <summary>
  96. ///
  97. /// </summary>
  98. public override void Run()
  99. {
  100. Logger.Debug("怪物心跳检查器 执行线程:" + System.Threading.Thread.CurrentThread.Name);
  101. Logger.Debug("怪物心跳检查器 检查怪物是否需要复活,需要回血,是否回跑");
  102. //var scripts = Sz.ScriptPool.ScriptManager.Instance.GetInstances<IMonsterHeartTimerScript>();
  103. //foreach (var item in scripts)
  104. //{
  105. // item.Run(serverID, lineID, mapID, mapModelID);
  106. //}
  107. }
  108. }
  109. }
  110.  
  111. using System;
  112. using System.Collections.Generic;
  113. using System.Linq;
  114. using System.Text;
  115. using System.Threading.Tasks;
  116.  
  117. /**
  118. *
  119. * @author 失足程序员
  120. * @Blog http://www.cnblogs.com/ty408/
  121. * @mail 492794628@qq.com
  122. * @phone 13882122019
  123. *
  124. */
  125. namespace Sz.MMO.GameServer.TimerMonster
  126. {
  127. /// <summary>
  128. ///
  129. /// </summary>
  130. public class MonsterRunTimer: ThreadPool.TimerTask
  131. {
  132.  
  133. int serverID, lineID, mapModelID;
  134. long mapID;
  135.  
  136. /// <summary>
  137. /// 指定1秒执行一次
  138. /// </summary>
  139. public MonsterRunTimer(int serverID, int lineID, long mapID, int mapModelID)
  140. : * )
  141. {
  142. this.serverID = serverID;
  143. this.lineID = lineID;
  144. this.mapID = mapID;
  145. this.mapModelID = mapModelID;
  146. }
  147.  
  148. /// <summary>
  149. ///
  150. /// </summary>
  151. public override void Run()
  152. {
  153. Logger.Debug("怪物移动定时器任务 执行线程:" + System.Threading.Thread.CurrentThread.Name);
  154. Logger.Debug("怪物移动定时器任务 怪物随机移动和回跑");
  155. //var scripts = Sz.ScriptPool.ScriptManager.Instance.GetInstances<IMonsterHeartTimerScript>();
  156. //foreach (var item in scripts)
  157. //{
  158. // item.Run(serverID, lineID, mapID, mapModelID);
  159. //}
  160. }
  161. }
  162. }

就在初始化地图线程的时候加入定时器任务

  1. )
  2. {
  3.  
  4. this.MapID = SzExtensions.GetId();
  5. this.MapModelID = mapModelId;
  6. Logger.Debug("开始初始化地图: " + name + " 地图ID:" + MapID);
  7.  
  8. ; i <= lineCount; i++)
  9. {
  10. MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods> lineInfo = new MapLineInfo<TPlayer, TNpc, TMonster, TDropGoods>(name + "-" + i + "线");
  11. //添加地图心跳检测器
  12. lineInfo.MapServer.AddTimerTask(new MapHeartTimer(ServerID, i, MapID, MapModelID));
  13. //添加怪物移动定时器
  14. lineInfo.MapServer.AddTimerTask(new MonsterRunTimer(ServerID, i, MapID, MapModelID));
  15. //添加怪物心跳检测器
  16. lineInfo.MapServer.AddTimerTask(new MonsterHeartTimer(ServerID, i, MapID, MapModelID));
  17.  
  18. mapLineInfos[i] = lineInfo;
  19. }
  20. Logger.Debug("初始化地图: " + name + " 地图ID:" + MapID + " 结束");
  21. }
  1. 其实所有的任务定时器处理都是交给了timer线程,timer线程只负责查看该定时当前是否需要执行。而具体的任务执行移交到线程执行器。线程执行器是按照队列方式执行。保证了timer线程只是一个简单的循环处理而不至于卡死同样也保证了在同一张地图里面各个单元参数的线程安全性。

来看看效果。

为了方便我们看清楚一点,我把地图线程改为以一条线。

这样就完成了各个定时器在规定时间内处理自己的事情。

  1. 需要注意的是这里只是简单的模拟的一个地图处理各种事情,最终都是由一个线程处理的。那么肯定有人要问了。你一个线程处理这些事情能忙得过来嘛?有两点需要注意1,你的每一个任务处理处理耗时是多久,换句话说你可以理解为你一秒钟能处理多少个任务。2,你的地图能容纳多少怪物,多少玩家,多少掉落物?换句话说也就是你设计的复杂度间接限制了你的地图有多少场景对象。

那么还有什么需要注意的呢?

  1. 其实地图最大的消耗在于寻路。高性能的寻路算法和人性化寻路算法一直是大神研究的对象,我也只能是借鉴他们的了。

这一章我只是简单的阐述了地图运行和任务等划分和构成已经任务处理流程。

接下来我会继续讲解游戏服务器编程,一步一步的剖析。

文路不是很清晰。希望大家不要见怪。

一步一步开发Game服务器(四)地图线程的更多相关文章

  1. 微信小程序开发教程(四)线程架构与开发步骤

    线程架构 从前面的章节我们可以知道,.js文件是页面逻辑处理层.我们可以按需在app.js和page.js中添加程序在生命周期的每个阶段相应的事件.如在页面的onLoad时进行数据的下载,onShow ...

  2. 一步一步开发Game服务器(三)加载脚本和服务器热更新(二)完整版

    上一篇文章我介绍了如果动态加载dll文件来更新程序 一步一步开发Game服务器(三)加载脚本和服务器热更新 可是在使用过程中,也许有很多会发现,动态加载dll其实不方便,应为需要预先编译代码为dll文 ...

  3. 一步一步开发Game服务器(一)

    什么是服务器?对于很多人来说也许只是简单成为在服务器端运行的程序的确如此,服务器通常意义就是说在服务器端运行的程序而已.那么我们怎么理解和分析游戏服务器哪? 传统意义上来说,程序运行后,正常流程, 启 ...

  4. 如何一步一步用DDD设计一个电商网站(四)—— 把商品卖给用户

    阅读目录 前言 怎么卖 领域服务的使用 回到现实 结语 一.前言 上篇中我们讲述了“把商品卖给用户”中的商品和用户的初步设计.现在把剩余的“卖”这个动作给做了.这里提醒一下,正常情况下,我们的每一步业 ...

  5. 一步一步学ZedBoard & Zynq(四):基于AXI Lite 总线的从设备IP设计

    本帖最后由 xinxincaijq 于 2013-1-9 10:27 编辑 一步一步学ZedBoard & Zynq(四):基于AXI Lite 总线的从设备IP设计 转自博客:http:// ...

  6. 跟我一步一步开发自己的Openfire插件

    http://www.blogjava.net/hoojo/archive/2013/03/07/396146.html 跟我一步一步开发自己的Openfire插件 这篇是简单插件开发,下篇聊天记录插 ...

  7. 一步一步实现HTTP服务器-开篇

    缘起 翻开清单,一条条计划一直列在那里,一天又一天,不知道什么时候写下了它,也知不道什么时候完成它,它一直在那静静的等待着. 静下心来,反思自己,才发现自己是多么的无知,多么的没有毅力.设定了无数目标 ...

  8. 一步一步构建手机WebApp开发——页面布局篇

    继上一篇:一步一步构建手机WebApp开发——环境搭建篇过后,我相信很多朋友都想看看实战案例,这一次的教程是页面布局篇,先上图: 如上图所示,此篇教程便是教初学者如何快速布局这样的页面.废话少说,直接 ...

  9. 一步一步构建手机WebApp开发——环境搭建篇

    从2007年,乔布斯带来了第一代Iphone手机,整个移动互联网发生天翻地覆的变化,也同时证明了乔布斯的一句名言:“再一次改变世界”. 在当今的移动互联网,手机App居多,很多App对移动设备的要求也 ...

随机推荐

  1. Python高手之路【四】python函数装饰器

    def outer(func): def inner(): print('hello') print('hello') print('hello') r = func() print('end') p ...

  2. Asp.Net MVC中使用StreamReader读取“Post body”之应用场景。

    场景:有三个市场(Global.China.USA),对前台传过来的数据有些验证需要细化到每个市场去完成. 所以就出现了基类(Global)和派生类(China.USA) 定义基类(Global)Pe ...

  3. 比Mysqli操作数据库更简便的方式 。PDO

    下面来说一下PDO 先画一张图来了解一下 mysqli是针对mysql这个数据库扩展的一个类 PDO是为了能访问更多数据库 如果出现程序需要访问其他数据库的话就可以用PDO来做 PDO数据访问抽象层1 ...

  4. HDU1671——前缀树的一点感触

    题目http://acm.hdu.edu.cn/showproblem.php?pid=1671 题目本身不难,一棵前缀树OK,但是前两次提交都没有成功. 第一次Memory Limit Exceed ...

  5. XML技术之DOM4J解析器

    由于DOM技术的解析,存在很多缺陷,比如内存溢出,解析速度慢等问题,所以就出现了DOM4J解析技术,DOM4J技术的出现大大改进了DOM解析技术的缺陷. 使用DOM4J技术解析XML文件的步骤? pu ...

  6. css居中div的几种常用方法

    在开发过程中,很多需求需要我们居中一个div,比如html文档流当中的一块div,比如弹出层内容部分这种脱离了文档流等.不同的情况有不同的居中方式,接下来就分享下一下几种常用的居中方式. 1.text ...

  7. 后缀数组的倍增算法(Prefix Doubling)

    后缀数组的倍增算法(Prefix Doubling) 文本内容除特殊注明外,均在知识共享署名-非商业性使用-相同方式共享 3.0协议下提供,附加条款亦可能应用. 最近在自学习BWT算法(Burrows ...

  8. 关于SMARTFORMS文本编辑器出错

    最近在做ISH的一个打印功能,SMARTFORM的需求本身很简单,但做起来则一波三折. 使用环境是这样的:Windows 7 64bit + SAP GUI 740 Patch 5 + MS Offi ...

  9. 好用的Markdown编辑器一览 readme.md 编辑查看

    https://github.com/pandao/editor.md https://pandao.github.io/editor.md/examples/index.html Editor.md ...

  10. ORACLE从共享池删除指定SQL的执行计划

    Oracle 11g在DBMS_SHARED_POOL包中引入了一个名为PURGE的新存储过程,用于从对象库缓存中刷新特定对象,例如游标,包,序列,触发器等.也就是说可以删除.清理特定SQL的执行计划 ...