java构建内存池队列_GitHub - ketoo/shmqueue: 基于c++内存池,共享内存和信号量实现高速的进程间通信队列,单进程读单进程写无需加锁,多进程读多进程写用信号量集实现读写锁保证...

测试结果:

===============================================================

Try to malloc share memory of 10240 bytes...

Successfully alloced share memory block, (key=12345), id = 11272200, size = 10240

Mem trunk address 0x0x7ffff7ff4000,key 11272200 , size 10240, begin 0, end 0, queue module 0

Write SingleRWTest thread 1 ,write count 1000000

Read SingleRWTest ,thread 1 ,read count 1000000

Touch to share memory key = 12345...

Now remove the exist share memory 11272200

Remove shared memory(id = 11272200, key = 12345) succeed.

=======================SingleRWTest=============================

SingleRWTest cost time 3046 ms

Read read_count 1000000

Write write_count 1000000

SingleRWTest ok 0

===============================================================

Try to malloc share memory of 10240 bytes...

Successfully alloced share memory block, (key=1234), id = 11304977, size = 10240

Mem trunk address 0x0x7ffff7ff1000,key 11304977 , size 10240, begin 0, end 0, queue module 3

===============================================================

Write MulRWTest thread 4 ,write count 100000

Write MulRWTest thread 1 ,write count 100000

Write MulRWTest thread 0 ,write count 100000

Write MulRWTest thread 3 ,write count 100000

Write MulRWTest thread 2 ,write count 100000

Read MulRWTest ,thread 3 ,read count 99981

Read MulRWTest ,thread 1 ,read count 104765

Read MulRWTest ,thread 2 ,read count 104513

Read MulRWTest ,thread 4 ,read count 95279

Read MulRWTest ,thread 0 ,read count 95467

Touch to share memory key = 1234...

Now remove the exist share memory 11304977

Remove shared memory(id = 11304977, key = 1234) succeed.

=======================MulRWTest===============================

MulRWTest cost time 24639 ms

Read read_count 500000

Write write_count 500000

MulRWTest ok

为了操作方便,这里的读写操作用全部用线程代替进程,从目的上来说效果是一样的

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值