Delphi-Cross-Socket
Delphi-Cross-Socket copied to clipboard
什么时候能时候能够实现无锁化?(Do you have a plan of no locker for threads?)
有无锁化的计划吗?Do you have a plan of no locker for threads?
无锁就是cas,有时性能可能会更差!正在的无锁是线程独立运行,每个线程操作自己的部分,设计上非常麻烦
The library is multithreaded (CPUCount * 2 + 1), with each thread running independently without lockers
The library is multithreaded (CPUCount * 2 + 1), with each thread running independently without lockers
TMonitor.Enter is used in many places in the code, so locks are used!
最主要的是CreateConnection,不停创建对象,这个从MM管理器中申请内存,是使用锁的!最好使用无锁对象池!
@pony5551 You're right! I only use the TCP server with my own protocol, but even in my case CrossSocket actively uses 1 TMonitor, which is the connection one, to have the list of active connections. This lock is inevitable, but what can be done is to reduce the operations inside the locks as much as possible reviewing all locks. One simple example is here https://github.com/winddriver/Delphi-Cross-Socket/pull/77/commits/f5ffd2125fa11991c5d3f91169643854f8931e45