Giter VIP home page Giter VIP logo

wfmpmc's Issues

getThrIdx()

这个函数虽然是个while,但是这么看都只运行了一次吧!?

距离工程化还差一个cond

如果队列为空,while (try read); 是一个会把cpu core吃满的操作,在实际工程中适用范围很小。

此处需要一个std::condition_variable来等待,引入condition又会有新的问题,不是使用者直接引入就能解决的,应该还是需要wait-free队列处理好这个事情。

Not lock-free

"Even worse, if a writer holding an index crashes before committing, then the corresponding reader will never succeed in reading one element even if other writer has completed a write operation. This is the reason why WFMPMC is not strict wait-free."
Well, with this behaviour it is not even lock-free as lock-freedom requires system-wide progress (some thread must make progress) even if one thread fails or blocks.

With loops like this: "while((data = getWritable(idx)) == nullptr);", it is actually blocking. Essentially, each individual slot is protected by its own lock (which allows for alternating enqueues and dequeues). Any thread that continues to enqueue/dequeue objects will eventually attempt to access all slots, including any slot that is blocked.

在shm上发现一个问题,少调用了构造函数

在shm_comm.h中, 函数shmmap()里面,在 ret->shmInit();语句之前,少了一个 调用T构造函数。
'''
T* ret = (T*)mmap(0, sizeof(T), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
close(fd);

if(ret == MAP_FAILED) 
{
    std::cerr << "mmap failed: " << strerror(errno) << std::endl;
    return nullptr;
}

new(ret) T(); //这一句

ret->shmInit();

'''

会导致一个问题是,mmap的文件如果是存在的,WFMPMC对象在共享内存上没有调用构造函数,导致readidx,wirteidx 没有正确赋值

init初始化的时候死循环

WFMPMC.h 57行那里,init_state我遇到了一种情况:init_state 为一个2打头的随机值,然后就卡在那行

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.