Skip to content

Commit

Permalink
modernize SwapBufferGuard
Browse files Browse the repository at this point in the history
  • Loading branch information
malytomas committed Jan 16, 2025
1 parent 40e2b01 commit 26767e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
11 changes: 3 additions & 8 deletions sources/libcore/swapBufferGuard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace cage
class SwapBufferGuardImpl : public SwapBufferGuard
{
public:
explicit SwapBufferGuardImpl(const SwapBufferGuardCreateConfig &config) : states{ StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing }, ri(0), wi(0), buffersCount(config.buffersCount), repeatedReads(config.repeatedReads), repeatedWrites(config.repeatedWrites)
explicit SwapBufferGuardImpl(const SwapBufferGuardCreateConfig &config) : buffersCount(config.buffersCount), repeatedReads(config.repeatedReads), repeatedWrites(config.repeatedWrites)
{
CAGE_ASSERT(buffersCount > 1 && buffersCount < 5);
CAGE_ASSERT(buffersCount > 1u + repeatedReads + repeatedWrites);
Expand Down Expand Up @@ -118,11 +118,9 @@ namespace cage

uint32 next(uint32 i) const { return (i + 1) % buffersCount; }

uint32 prev(uint32 i) const { return (i + buffersCount - 1) % buffersCount; }

Holder<Mutex> mutex;
StateEnum states[4];
uint32 ri, wi;
StateEnum states[4] = { StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing, StateEnum::Nothing };
uint32 ri = 0, wi = 0;
const uint32 buffersCount;
const bool repeatedReads, repeatedWrites;
};
Expand Down Expand Up @@ -179,9 +177,6 @@ namespace cage
return impl->write();
}

//SwapBufferGuardCreateConfig::SwapBufferGuardCreateConfig(uint32 buffersCount) : buffersCount(buffersCount)
//{}

Holder<SwapBufferGuard> newSwapBufferGuard(const SwapBufferGuardCreateConfig &config)
{
return systemMemory().createImpl<SwapBufferGuard, SwapBufferGuardImpl>(config);
Expand Down
4 changes: 2 additions & 2 deletions sources/libsimple/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ namespace cage
struct EmitSound
{
TransformComponent transform, transformHistory;
SoundComponent sound = {};
SoundComponent sound;
uintPtr id = 0;
};

struct EmitListener
{
TransformComponent transform, transformHistory;
ListenerComponent listener = {};
ListenerComponent listener;
uintPtr id = 0;
};

Expand Down

0 comments on commit 26767e1

Please sign in to comment.