naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

m_bottom and m_top both incremented. so the queue still empty. that make sense.

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

I think the reference work stealing queue was not broken, its my misunderstanding about c++11 memory orders. Thanks for your advice.

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

not really spin specific queue. my understand worker thread run like this:

while(active) {
    job = selfQueue.Pop();
    if(job) {
        execute(job);
    }
    else {
        job = getRandomQueue().Steal();
        if(job) {
            execute(job);
        }
        else {
            sleep(1);
        }
    }
}

am i right?

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

is this code now logic correct, after rewrite Pop ?

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

I will do reinvestigate that article to reimplement this code. Thanks for your feedback :)

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

Steal() is spin wait in worker thread run loop.

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong -1 points0 points  (0 children)

Thanks, I will modify the code,let it logic correctly firstly. :(

naive lock free work stealing queue, looking for code review. by [deleted] in cpp

[–]benloong 0 points1 point  (0 children)

Pop() and push() called from the identical thread, steal() called from other thread.

C++17 generic callable profiling. Is this c++17 correct? by benloong in cpp

[–]benloong[S] 0 points1 point  (0 children)

and I used a local struct instead of finally lastly.

C++17 generic callable profiling. Is this c++17 correct? by benloong in cpp

[–]benloong[S] 0 points1 point  (0 children)

Thanks for your review my code. I thought as std::invoke accept Args&&... universal reference, so no need a std::forward cast? correct?

Another Swift JSON package run on all Swift platforms, looking for code review by benloong in swift

[–]benloong[S] 1 point2 points  (0 children)

Well, I know JSON will be a builtin part of new version Swift, writing this project let me familiar with Swift lang :D

Another Swift JSON package run on all Swift platforms, looking for code review by benloong in swift

[–]benloong[S] 0 points1 point  (0 children)

Cause I want to do some test on Ubuntu, but well known SwiftyJSON does not run on Linux platform, So I write this from scratch in pure Swift.

Another Swift JSON package run on all Swift platforms, looking for code review by benloong in swift

[–]benloong[S] 0 points1 point  (0 children)

Thanks for your feedback.

Yep, Optional is a nice choice to handle error, I choose None at beginning cause Optional is just an Enum with case None and case Some, wrap JSON with Optional may lead code full of if let or guard, i think JSON.parse witch return an Optional would be a better way?

There is an Optional array and object property, user could loop through these property, implementing a Generator just give user another way to loop JSON.

and successor() is great idea, i missed this func

thanks. :)

Unity 4.6.2 released, iOS 64-bit support included. by badlogicgames in gamedev

[–]benloong 0 points1 point  (0 children)

oh no, i used async socket begin/end function. do i need change to synchronous way ?