Shared an non-shared

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 6 11:59:11 PDT 2016


On Wednesday, October 05, 2016 21:10:01 Begah via Digitalmars-d-learn wrote:
> Although the triple buffer seems a good idea, there is one
> problem.
> I will need three time as much ram than what i currently need.
> Not to mention, every time i switch buffer i will need to copy
> all changes made to the updated buffer to the next buffer to be
> updated (Which i think, doing it a few hundred times a second
> might become a bottleneck ).

Well, I certainly can't tell what the exact best solution is in your case,
but if you can't do some kind of buffer swapping, I wouldn't think that
there's any point in separating the update and render threads, because if
you only have one buffer to deal with, the update thread can't actually
update anything while the render thread renders it, because otherwise, the
render thread would be accessing data while the update thread mutated it.
And properly protecting that code with a mutex would force each thread to
wait for the other would pretty much negate the benefits of putting that
code in separate threads. Certainly, the way that your typical grahpics
stuff paints things involves some variant of double or triple buffering. But
since I obviously don't know all of the details of your problem, I can't
really give better advice.

In any case, hopefully you understand the shared stuff and mutex stuff well
enough now to figure out what works best for your particular use case.

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list