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

福州网站建设 网站设计 网站制作做建材一般去什么网站宣传

福州网站建设 网站设计 网站制作,做建材一般去什么网站宣传,.net和php那个做网站好,网站怎么做1.入口 会调用到父类SingleThreadEventLoop的构造方法 2.SingleThreadEventLoop 继续调用父类SingleThreadEventExecutor的构造方法 3.SingleThreadEventExecutor 到这里完整的总结一下#xff1a; 将线程执行器保存到每一个SingleThreadEventExcutor里面去创建了MpscQu… 1.入口 会调用到父类SingleThreadEventLoop的构造方法 2.SingleThreadEventLoop 继续调用父类SingleThreadEventExecutor的构造方法 3.SingleThreadEventExecutor 到这里完整的总结一下 将线程执行器保存到每一个SingleThreadEventExcutor里面去创建了MpscQueue具体为什么因为在NioEventLoop里面重写了newTaskQueue方法 等父类调用完毕最后回到NioEventLoop里面最重要的一件事创建Selector 最后那一张图完整的总结一下 4.NioEventLoop.run 4.1 调用入口 这里还是要回顾一下这个方法是什么时候调用的Netty在启动的时候在调用config().group().register(channel) 使用bossGroup做channel注册的时候它会使用EventExecutorChooser找一个NioEventLoop然后去做注册最终会调用到这个abstractChannel.register方法一般来说我们启动的时候运行到这里eventLoop会返回false所以会调用到eventLoop.execute里面的方法在这里我们就能找到这个NioEventLoop.run的调用地方也就说在使用NioEventLoop将channel注册到selector的时候会判断是不是eventloop线程调用如果不是就会使用SingleThreadEventExecutor.execute执行它会将NioEventLoop.run方法包装成一个runnable然后创建一个线程并启动然后就调用到NioEventLoop里面了 4.2 run方法 /*** todo select() 检查是否有IO事件* todo ProcessorSelectedKeys() 处理IO事件* todo RunAllTask() 处理异步任务队列*/ Override protected void run() {for (; ; ) {try {// todo hasTasks() true代表 任务队列存在任务switch (selectStrategy.calculateStrategy(selectNowSupplier, hasTasks())) {case SelectStrategy.CONTINUE:continue;case SelectStrategy.SELECT:// todo 轮询IO事件, 等待事件的发生, 本方法下面的代码是处理接受到的感性趣的事件, 进入查看本方法select(wakenUp.getAndSet(false));// wakenUp.compareAndSet(false, true) is always evaluated// before calling selector.wakeup() to reduce the wake-up// overhead. (Selector.wakeup() is an expensive operation.)//// However, there is a race condition in this approach.// The race condition is triggered when wakenUp is set to// true too early.//// wakenUp is set to true too early if:// 1) Selector is waken up between wakenUp.set(false) and// selector.select(...). (BAD)// 2) Selector is waken up between selector.select(...) and// if (wakenUp.get()) { ... }. (OK)//// In the first case, wakenUp is set to true and the// following selector.select(...) will wake up immediately.// Until wakenUp is set to false again in the next round,// wakenUp.compareAndSet(false, true) will fail, and therefore// any attempt to wake up the Selector will fail, too, causing// the following selector.select(...) call to block// unnecessarily.//// To fix this problem, we wake up the selector again if wakenUp// is true immediately after selector.select(...).// It is inefficient in that it wakes up the selector for both// the first case (BAD - wake-up required) and the second case// (OK - no wake-up required).if (wakenUp.get()) {selector.wakeup();}// fall throughdefault:}cancelledKeys 0;needsToSelectAgain false;final int ioRatio this.ioRatio; // todo 默认50// todo 如果ioRatio100 就调用第一个 processSelectedKeys(); 否则就调用第二个if (ioRatio 100) {try {// todo 处理 处理发生的感性趣的事件processSelectedKeys();} finally {// Ensure we always run tasks.// todo 用于处理 本 eventLoop外的线程 扔到taskQueue中的任务runAllTasks();}} else {// todo 因为ioRatio默认是50 , 所以来else// todo 记录下开始的时间final long ioStartTime System.nanoTime();try {// todo 处理IO事件processSelectedKeys();} finally {// Ensure we always run tasks.// todo 根据处理IO事件耗时 ,控制 下面的runAllTasks执行任务不能超过 ioTime 时间final long ioTime System.nanoTime() - ioStartTime;// todo 这里面有聚合任务的逻辑runAllTasks(ioTime * (100 - ioRatio) / ioRatio);}}} catch (Throwable t) {handleLoopException(t);}// Always handle shutdown even if the loop processing threw an exception.try {if (isShuttingDown()) {closeAll();if (confirmShutdown()) {return;}}} catch (Throwable t) {handleLoopException(t);}}} 这里注释其实说得挺清楚最后总结一下 select(wakenUp.getAndSet(false))轮训io事件发生当timeout或者有事件会breakprocessSelectedKeys处理io事件运行taskQueue里面的任务 4.3 processSelectedKeys 在真正执行的时候最终会走到processSelectedKeysOptimizednetty对底层selectKeys容器进行过优化用数组代替了keyset 这里我为了debug使用telnet localhost 8899, 接着就会进入到processSelectedKeysOptimized中在走进processSelectedKey方法之后最终会走到unsafe.read方法 5.AbstractNioMessageChannel 接着会调用到子类NioServerSocketChannel的doReadMessage(readBuf), 调用完子类之后会通过pipline.fireChannelRead, 意思就是对于server端来说可读了但是注意这时候传的是子类中创建的NioSocketChannel说白了给server端一个NioSocketChannel就是要创建新连接了。最终会调用到ServerBootstrapAcceptor的ChannelRead具体看后面的ServerBootStrapAcceptor类 6.NioServerSocketChannel 这里主要做了几件事 SocketUtils.accpet接受连接并创建jdk底层的socketChannelnew NioSocketChannel将jdk封装成NioSocketChannel这里和创建NioServerSocketChannel的时候一样不断的调用父类同时创建NioServerChannel的pipline这里注意这里会设置感兴趣的事件为read 7.ServerBootstrap#ServerBootstrapAcceptor ServerBootstrapAcceptor是ServerBootstrap的内部类之前AbstractNioMessageChannel里面的最终会调用到ServerBootstrapAcceptor的channelRead方法简单的总结一下做了几件事 给sockeChannel也是这里的child设置childHandler使用childGroup.register 来完成socketChannel到Selector的注册这里和SocketServerChannel到Selector的注册逻辑是一样的都是从EventLoopGroup中选一个EventLoop里面有Selector然后调用jdk的registereventloop.getSelector, 0, NioSocketChannel(netty对于socketChannel的包装) 8.AbstractChannel childGroup.register - MultithreadEventLoopGroup.register - SingleThreadEventLoop.register - AbstractChannel.registerAbstractChannel.abstractUnsafe.register 这一刻代码之前都讲过就是把创建socketChannel注册到EventLoop上的Selector上去AbstractChannel.register0(): doRegister: 完成了SocketChannel到Selector的注册pipeline.invokeHandlerAddedIfNeeded: 这里会调用之前我们设置MyServerInitializer.initChannel(), 会往SocketChannel的pipeline中加入一系列读写用到的Handler 9.总结 最后那一张图总结一下
http://www.w-s-a.com/news/722188/

相关文章:

  • 网站开发团队成员皮具网站建设
  • 国外外贸需求网站响应式布局网页
  • 手机端便民服务平台网站建设昆明网络哪家好
  • 产品网站建设找哪家舟山信息港
  • 唐山网站建设汉狮怎么样seol英文啥意思
  • 深圳小程序网站开发公司网页制作模板视频教程
  • 电子商务网站开发开题报告wordpress更改后台地址
  • 网站静态前端是什么工作
  • 餐饮门户网站 方案怎么做创业好项目
  • 做百度手机网站推广普通话的宣传标语
  • 记事本可以做网站吗网站服务器是主机吗
  • 手机网站被拦截怎么办怎么解决东营建设信息网网
  • 外贸网站模板免费微信网站开发技术
  • 视频盗版网站怎么做福州网站seo
  • 成都金铭 网站建设做网站包含的技术
  • 长沙的网站建设公司哪家好做网站应选那个主题
  • 公司网站百度搜不到如何自己做一个网站
  • 学生如何建设网站网站开发程序
  • 网站建设公司哪家好 皆来磐石网络网站建设"淘宝网" 在颜色选取和搭配方面有哪些值得学习的地方.
  • 网站如何做移动规则适配北京住房与城乡建设部网站
  • 课堂阵地建设网站wordpress运行机制
  • 网站建设的需求方案企业网站建设费用明细
  • 创口贴网站模板京创影视app
  • 团购网站建设目的网站有很多304状态码
  • 运用阿里云怎么做网站外资企业可以在中国境内做网站吗
  • 云南住房和城乡建设局网站西安做官网的公司
  • 企业网站图片上传网站建设和应用的情况
  • 网站不显示内容吗聊城网架公司
  • 南昌网站建设企业网站托管外包怎么做
  • 做非洲外贸的网站网站可以用PS设计吗