Git Product home page Git Product logo

Comments (2)

MacroGu avatar MacroGu commented on May 5, 2024

As showed before, does the load file or wait for some task finished required by the program to run, if it is, I think there is no way to optimize it, but I suggest that, we could load all file and some necessary task when the program initialize, and do some normal operations of storing data to container or parsing. use big memory and a lot of time during start up initialize to get a faster and easy program running later.

if not, we could use observer Pattern to solve this program, load file module hold an instance of the main module, after load file finished or task is finished, use that instance to notice main module do other thing.

上面说的加载文件和等待某个任务完成,是不是程序运行下去的必要条件, 如果是,我觉得没法优化, 但是建议程序在开始运行的时候,初始化加载全部需要的文件, 并且做一些固定的存储容器和解析的操作。用大的内存来和长的初始化时间换取程序后面运行的方便和快速。

如果不是,是不是可以用 observer 模式来解决这个问题, 加载文件的模块保留一个 主模块的对象, 在完成加载或者任务完成之后,再通知主模块进行其他的任务。

from noahgameframe.

ketoo avatar ketoo commented on May 5, 2024

@MacroGu Yes, basically, people loaded all the resources that the application required when launching the application.

Observer Pattern you mentioned is a good way to solve the problem that the task blocking the main thread. The disadvantage of this way is it needs a callback function to receive the notice when the task finished, which is unfriendly in terms of synchronizing code.

Actually, some coder hopes all the business code run in one thread and with a high performance, besides, the function can transfer its context and can restore its context when the program needs.

The answer is Coroutine.

The project https://github.com/ketoo/NFCoroutine now I am writing is a demo about Coroutine. Another project https://github.com/cloudwu/coroutine written by Cloud.Wu is the same kind of project.

from noahgameframe.

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.