The invention provides a circular buffer pool memory read and write methods, including cyclic memory data writing method and cycle storage data reading method; cycle memory data writing method comprises the following steps: creating a buffer pool, and ready to write data; detecting write data length, if the write data is less than the length of the remaining space is the end of the time if the data is written, the write data is larger than the length of the remaining space to write data to the cache; detecting whether the end, if the write pointer to the buffer at the start to move backwards and the end of the number according to the written, if not the write pointer moves backward and the end of the write data storage data reading method includes circulation; the following steps: acquiring data length; data read; detecting whether to cache the end, if it will move the pointer to read The cache starts to move backwards and ends the data read, otherwise the read pointer moves backwards and ends the data read.
【技术实现步骤摘要】
缓冲池循环存储读写方法
本专利技术具体涉及一种缓冲池循环存储读写方法。
技术介绍
循环缓冲区用于表示一个固定尺寸、头尾相连的缓冲区,适合缓存数据流的一种数据结构,现有循环缓冲区读写方法并不能满足日常工作需要,因此急需一种缓冲池循环存储读写方法以解决这一问题。
技术实现思路
本专利技术的目的在于针对现有技术的不足,提供一种缓冲池循环存储读写方法,该缓冲池循环存储读写方法可以很好地解决上述问题。为达到上述要求,本专利技术采取的技术方案是:提供一种缓冲池循环存储读写方法,该缓冲池循环存储读写方法包括循环存储数据写入方法和循环存储数据读取方法;循环存储数据写入方法包括如下步骤:S1:创建缓冲池,并准备写入数据;S2:检测写入数据的长度,若写入数据的长度小于剩余空间则结束本次数据写入,若所述写入数据的长度大于剩余空间则进行数据写入;S3:检测是否到缓存末尾,若是则将写指针移动到缓存起始处再向后移动并结束本次数据写入,若否将写指针向后移动并结束本次数据写入;循环存储数据读取方法包括如下步骤:S1:获取读取数据的长度;S2:进行数据读取;S3:检测是否到缓存末尾,若是则将将读指针移动到缓存起始处再向后移动并结束本次数据读取,若否则将读指针向后移动并结束本次数据读取。该缓冲池循环存储读写方法具有的优点如下:该缓冲池循环存储读写方法开辟一块连续的存储区,可以不断地读、写数据,当写入到存储区的末尾的时候,再从存储区的首部再开始写入数据,由此不断地重复下去构成了循环缓冲池,缓冲池可以存储多次的接收数据,待需要时按循序取出。附图说明此处所说明的附图用来提供对本申请的进一步理解,构成本 ...
【技术保护点】
一种缓冲池循环存储读写方法,其特征在于:包括循环存储数据写入方法和循环存储数据读取方法;所述循环存储数据写入方法包括如下步骤:S1:创建缓冲池,并准备写入数据;S2:检测写入数据的长度,若所述写入数据的长度小于剩余空间则结束本次数据写入,若所述写入数据的长度大于剩余空间则进行数据写入;S3:检测是否到缓存末尾,若是则将写指针移动到缓存起始处再向后移动并结束本次数据写入,若否将写指针向后移动并结束本次数据写入;所述循环存储数据读取方法包括如下步骤:S1:获取读取数据的长度;S2:进行数据读取;S3:检测是否到缓存末尾,若是则将将读指针移动到缓存起始处再向后移动并结束本次数据读取,若否则将读指针向后移动并结束本次数据读取 。
【技术特征摘要】
1.一种缓冲池循环存储读写方法,其特征在于:包括循环存储数据写入方法和循环存储数据读取方法;所述循环存储数据写入方法包括如下步骤:S1:创建缓冲池,并准备写入数据;S2:检测写入数据的长度,若所述写入数据的长度小于剩余空间则结束本次数据写入,若所述写入数据的长度大于剩余空间则进行数据写入;S3:检测是否到缓存末尾,若是则将写指针移动到缓存起始处再向后移动并结束本次数据写入,若否将写指针向后移动并结束本次数据写入;所述循...
【专利技术属性】
技术研发人员:付晓,杨俊,樊银兵,张乾,
申请(专利权)人:成都华立达电力信息系统有限公司,
类型:发明
国别省市:四川,51
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。