Lua :: How to write simple program that will load multiple CPUs?

后端 未结 6 662
猫巷女王i
猫巷女王i 2021-02-07 17:27

I haven\'t been able to write a program in Lua that will load more than one CPU. Since Lua supports the concept via coroutines, I believe it\'s achievable.

Reason for me

6条回答
  •  没有蜡笔的小新
    2021-02-07 18:12

    Serializing data via IPC-like transport mechanisms is not the only way to share data across threads.

    If you're programming in an object-oriented language like C++ then it's quite possible for multiple threads to access shared objects across threads via object pointers, it's just not safe to do so, unless you provide some kind of guarantee that no two threads will attempt to simultaneously read and write to the same data.

    There are many options for how you might do that, lock-free and wait-free mechanisms are becoming increasingly popular.

提交回复
热议问题