The present invention is applicable to the field of communication technology, and provides a method and device for message processing, including receiving messages and obtaining the first dormancy number of preset threads of the current processor; calculating the second dormancy number of preset threads of the processor corresponding to the elimination time of preset messages according to the preset dormancy length; and if the dormancy number of preset threads of the processor reaches the third dormancy number, The message is eliminated; the third dormancy number is equal to the first dormancy number plus the second dormancy number. The embodiment of the present invention enables threads to relinquish the use rights of processors, increase the efficiency of processors, avoid the bottleneck problem of system performance caused by high frequency system call acquisition time in the prior art, and overcome the delay of message burning due to system time error in the prior art, or instant burning without time to display. Or the burning time is too different from the design time.
【技术实现步骤摘要】
一种消息处理的方法及装置
本专利技术属于通讯
,尤其涉及一种消息处理的方法和装置。
技术介绍
在通信消息处理领域中,消息定时焚毁功能是使用非常广泛的,现有技术中大多数都是提前设置好接收到消息预设时长后将消息进行焚毁,通过读取接收消息时的CPU时间,当CPU时间达到消息焚毁的预设时长时,就将消息焚毁。CPU时间虽然不随系统时间修改而改变,但很多情况下CPU时间与系统时间不一致,可能会产生异常逻辑,导致读取的时间不准确。并且通过系统调用获取时间是相对消耗系统性能的操作,高频的使用系统调用获取时间导致了系统性能的瓶颈,使得CPU的占用率过高,导致定时焚毁功能失效。
技术实现思路
有鉴于此,本专利技术实施例提供了一种消息处理的方法,以解决现有技术中CPU时间与系统时间不一致,可能会产生异常逻辑,导致读取的时间不准确。并且通过系统调用获取时间是相对消耗系统性能的操作,高频的使用系统调用获取时间导致了系统性能的瓶颈,使得CPU的占用率过高,导致定时焚毁功能失效的问题。本专利技术实施例的第一方面提供了一种消息处理的方法,包括:接收消息并获取当前处理器预设线程的第一休眠次数;根 ...
【技术保护点】
1.一种消息处理的方法,其特征在于,包括:接收消息并获取当前处理器预设线程的第一休眠次数;根据预设休眠时长计算预设消息消除时长所对应的处理器预设线程的第二休眠次数;若处理器预设线程的休眠次数达到第三休眠次数,则将所述消息消除;所述第三休眠次数等于第一休眠次数加第二休眠次数。
【技术特征摘要】
1.一种消息处理的方法,其特征在于,包括:接收消息并获取当前处理器预设线程的第一休眠次数;根据预设休眠时长计算预设消息消除时长所对应的处理器预设线程的第二休眠次数;若处理器预设线程的休眠次数达到第三休眠次数,则将所述消息消除;所述第三休眠次数等于第一休眠次数加第二休眠次数。2.如权利要求1所述的方法,其特征在于,所述接收消息并获取当前处理器预设线程的第一休眠次数之前,还包括:设置处理器的预设线程重复进行休眠,并设置预设休眠时长。3.如权利要求2所述的方法,其特征在于,所述设置处理器的预设线程重复进行休眠,并设置预设休眠时长之后,还包括:通过计数器记录处理器预设线程的休眠次数。4.如权利要求1所述的方法,其特征在于,所述接收消息并获取当前处理器预设线程的第一休眠次数,包括:接收消息并读取计数器中记录的处理器预设线程的第一休眠次数。5.如权利要求1所述的方法,其特征在于,所述根据预设休眠时长计算预设消息消除时长所对应的预设线程的第二休眠次数,包括:通过公式“第二休眠次数=预设消息消除时长÷预设休眠时长”计算预设消息消除时长所对应的预设线程的第二休眠次数。6.一种消息处理的装置,其特征在于,包括:...
【专利技术属性】
技术研发人员:吴玲,黄敏强,
申请(专利权)人:深圳市景阳科技股份有限公司,
类型:发明
国别省市:广东,44
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。