Giter Site home page Giter Site logo

Comments (2)

bobbymly avatar bobbymly commented on May 11, 2024

是因为多个线程缓冲到同一个缓冲区里,只有这一个写入线程向文件中写入数据,所以负责写入文件的线程不需要线程安全是吗?

from webserver.

linyacool avatar linyacool commented on May 11, 2024

@bobbymly 在FileUtil里的append函数已经要直接往文件里面写了,可以保证只有这一个线程写,所以不需要保证线程安全。不同线程Log会有竞态,往同一个缓冲区写的时候已经加过锁了(可以认为只有一个线程接收),所以这里是安全的。这个log的设计我参考了muduo,但是简化了很多很多,只保留了基本**,可以看下这里最后我总结了一下:https://github.com/linyacool/WebServer/blob/master/%E5%B9%B6%E5%8F%91%E6%A8%A1%E5%9E%8B.md

from webserver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.