Skip to content

Commit

Permalink
Atomic ++, optustest fixed
Browse files Browse the repository at this point in the history
- volatile -> Atomic (finished)
- ozCore
  * Atomic
    + memory order as a template arg, checked with static_assert
    + fetchAnd(), fetchOr(), fetchXor()
    + threadFence()
    + operators =, &=, ++ etc.
- opustest fixed
  • Loading branch information
ducakar committed Mar 5, 2017
1 parent 963aa48 commit 231e9b9
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 128 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ endif()

find_package(OpenAL REQUIRED)
find_package(PNG REQUIRED)
pkg_check_modules(OGG REQUIRED ogg)
pkg_check_modules(OPUS REQUIRED opus)
pkg_check_modules(OPUSFILE REQUIRED opusfile)
pkg_check_modules(VORBISFILE REQUIRED vorbisfile)

Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ platforms=(
# Emscripten
# Linux-i686
# Linux-i686-Clang
Linux-x86_64
# Linux-x86_64
Linux-x86_64-Clang
# PNaCl
# Windows-i686
Expand Down
24 changes: 12 additions & 12 deletions src/client/Context.hh
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ private:
{
static const int BUFFER_SIZE = 44100;

uint id;
uint bufferIds[2];
int nQueuedBuffers;
int nSamples;

volatile int owner;
volatile bool isAlive; // Set to false to terminate source before it finishes.
Mutex mutex;
Thread thread;

String text;
short samples[BUFFER_SIZE];
uint id;
uint bufferIds[2];
int nQueuedBuffers;
int nSamples;

Atomic<int> owner;
Atomic<bool> isAlive; // Set to false to terminate source before it finishes.
Mutex mutex;
Thread thread;

String text;
short samples[BUFFER_SIZE];
};

private:
Expand Down
2 changes: 1 addition & 1 deletion src/client/EditStage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private:
Thread auxThread;
Semaphore mainSemaphore;
Semaphore auxSemaphore;
volatile bool isAuxAlive;
Atomic<bool> isAuxAlive;

public:

Expand Down
48 changes: 24 additions & 24 deletions src/client/GameStage.hh
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,34 @@ private:
// 2.5 min.
static const uint AUTOSAVE_INTERVAL;

ulong64 startTicks;
long64 sleepMicros;
long64 loadingMicros;
long64 uiMicros;
long64 loaderMicros;
long64 presentMicros;
long64 matrixMicros;
long64 nirvanaMicros;

uint autosaveTicks;

Stream saveStream;
File saveFile;
Thread saveThread;

Thread auxThread;
Semaphore mainSemaphore;
Semaphore auxSemaphore;
volatile bool isAuxAlive;
ulong64 startTicks;
long64 sleepMicros;
long64 loadingMicros;
long64 uiMicros;
long64 loaderMicros;
long64 presentMicros;
long64 matrixMicros;
long64 nirvanaMicros;

uint autosaveTicks;

Stream saveStream;
File saveFile;
Thread saveThread;

Thread auxThread;
Semaphore mainSemaphore;
Semaphore auxSemaphore;
Atomic<bool> isAuxAlive;

public:

Proxy* proxy;
Proxy* proxy;

File autosaveFile;
File quicksaveFile;
File stateFile;
String mission;
File autosaveFile;
File quicksaveFile;
File stateFile;
String mission;

private:

Expand Down
12 changes: 7 additions & 5 deletions src/client/Loader.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,16 @@ private:
static const uint SOUND_CLEAR_INTERVAL = 120 * Timer::TICKS_PER_SEC; // 2 min (+ 100 s)
static const uint SOUND_CLEAR_LAG = 100 * Timer::TICKS_PER_SEC;

Thread preloadThread;
private:

Thread preloadThread;

Semaphore preloadMainSemaphore;
Semaphore preloadAuxSemaphore;
Semaphore preloadMainSemaphore;
Semaphore preloadAuxSemaphore;

volatile bool isPreloadAlive;
Atomic<bool> isPreloadAlive;

uint tick;
uint tick;

private:

Expand Down
2 changes: 1 addition & 1 deletion src/client/Render.hh
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private:
Semaphore effectsMainSemaphore;
Semaphore effectsAuxSemaphore;

volatile bool areEffectsAlive;
Atomic<bool> areEffectsAlive;

public:

Expand Down
6 changes: 3 additions & 3 deletions src/client/Sound.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void Sound::musicRun()
}

if (streamedTrack >= 0) {
streamedBytes = musicDecoder.decode();
hasStreamedBytes = musicDecoder.decode();
}
}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ void Sound::updateMusic()
alGetSourcei(musicSource, AL_BUFFERS_PROCESSED, &nProcessed);

if (nProcessed != 0) {
if (streamedBytes) {
if (hasStreamedBytes) {
hasLoaded = true;

uint buffer;
Expand All @@ -151,7 +151,7 @@ void Sound::updateMusic()
}
}
// If beginning of a track.
else if (musicBuffersQueued != 2 && streamedBytes) {
else if (musicBuffersQueued != 2 && hasStreamedBytes) {
hasLoaded = true;

int i = musicBuffersQueued;
Expand Down
8 changes: 4 additions & 4 deletions src/client/Sound.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private:

// Music track id to switch to, -1 to do nothing, -2 stop playing.
int selectedTrack;
volatile int streamedTrack;
volatile bool streamedBytes;
Atomic<int> streamedTrack;
Atomic<bool> hasStreamedBytes;

Thread musicThread;
Thread soundThread;
Expand All @@ -64,8 +64,8 @@ private:
Semaphore soundMainSemaphore;
Semaphore soundAuxSemaphore;

volatile bool isMusicAlive;
volatile bool isSoundAlive;
Atomic<bool> isMusicAlive;
Atomic<bool> isSoundAlive;

public:

Expand Down
Loading

0 comments on commit 231e9b9

Please sign in to comment.