摘要
本方法涉及UDP并发技术领域,尤其涉及一种使用环形缓存和环形队列实现UDP高效并发的方法。特点如下:在数据接收线程中创建环形队列,用于存储待返回数据的客户端标识,并在数据处理子线程创建发送环形缓存和接收环形缓存,用于接收数据和存储待发送数据;数据接收线程在接收数据的同时查看环形队列中是否有需返回数据的客户端标识,如由相应数据处理子线程发送环形缓存中的数据发送出去。本方法的循环缓冲区可以提供对缓冲区的互斥访问,因而数据接收线程与数据处理子线程之间不需要加互斥保护,可同时进行,从而有了良好的并发性能,循环缓冲区可以更好地利用系统内存资源。
出处
《中国新技术新产品》
2016年第11期6-7,共2页
New Technology & New Products of China