- removed csfml-system dependency!

use phobos functionality for that

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1438 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
trass3r 2010-03-03 22:04:19 +00:00
parent b4189fd660
commit d60a7be49a
8 changed files with 9 additions and 406 deletions

View File

@ -30,12 +30,12 @@ import dsfml.audio.soundbuffer;
import dsfml.system.alloc;
import dsfml.system.common;
import dsfml.system.sleep;
import dsfml.system.linkedlist;
import dsfml.system.mutex;
import dsfml.system.lock;
//import dsfml.system.thread;
import core.thread;
import core.sync.mutex;
/**
* SoundRecorder is an interface for capturing sound data.
@ -252,7 +252,7 @@ private:
{
while (m_flag)
{
sleep(0.05f);
Thread.sleep(50_000_0); // 50ms
// if samples are available
if (!m_list.empty)
{

View File

@ -31,10 +31,9 @@ import dsfml.system.common;
import dsfml.system.vector3;
import dsfml.system.linkedlist;
import dsfml.system.lock;
import dsfml.system.mutex;
import dsfml.system.sleep;
//import dsfml.system.thread;
import core.thread;
import core.sync.mutex;
import dsfml.audio.sound;
import dsfml.audio.soundsource;
@ -251,7 +250,7 @@ private:
SoundStream temp = s_instances[id];
//if no samples are available but streaming is not stopped, we sleep the thread
while (temp.m_samples.empty && temp.m_flag)
sleep(0.01f);
Thread.sleep(10_000_0); // 10ms
scope Lock l = new Lock(temp.m_mutex);
if (!temp.m_samples.empty)
@ -294,7 +293,7 @@ private:
m_samples.enqueue(new Data(data, ret));
}
}
sleep(0.1f);
Thread.sleep(100_000_0); // 100ms
}
}

View File

@ -36,11 +36,6 @@ version (linux)
public import
dsfml.system.clock,
dsfml.system.lock,
dsfml.system.mutex,
dsfml.system.randomizer,
dsfml.system.sleep,
// dsfml.system.thread, // thread isn't used anywhere in the library and D threading is nice, so the user can safely use standard threads
dsfml.system.vector2,
dsfml.system.vector3;

View File

@ -1,101 +0,0 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.system.clock;
import dsfml.system.common;
/**
* Utility class for manipulating time
*/
class Clock : DSFMLObject
{
/**
* Default constructor
*/
this()
{
super(sfClock_Create());
}
/**
* Destructor
*/
override void dispose()
{
sfClock_Destroy(m_ptr);
}
/**
* Return the time elapsed since the last reset
* Returns:
* Elapsed Time in seconds
*/
float getElapsedTime()
{
return sfClock_GetTime(m_ptr);
}
/**
* Restart the timer
*/
void reset()
{
sfClock_Reset(m_ptr);
}
private:
// External ====================================================================
extern (C)
{
typedef void* function() pf_sfClock_Create;
typedef void function(void*) pf_sfClock_Destroy;
typedef float function(void*) pf_sfClock_GetTime;
typedef void function(void*) pf_sfClock_Reset;
static pf_sfClock_Create sfClock_Create;
static pf_sfClock_Destroy sfClock_Destroy;
static pf_sfClock_GetTime sfClock_GetTime;
static pf_sfClock_Reset sfClock_Reset;
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-system-d");
else
DllLoader dll = DllLoader.load("csfml-system");
sfClock_Create = cast(pf_sfClock_Create)dll.getSymbol("sfClock_Create");
sfClock_Destroy = cast(pf_sfClock_Destroy)dll.getSymbol("sfClock_Destroy");
sfClock_GetTime = cast(pf_sfClock_GetTime)dll.getSymbol("sfClock_GetTime");
sfClock_Reset = cast(pf_sfClock_Reset)dll.getSymbol("sfClock_Reset");
}
}
}

View File

@ -26,7 +26,7 @@
module dsfml.system.lock;
import dsfml.system.mutex;
import core.sync.mutex;
/**
* Encapsulation of an critical section. Unlocking is guaranteed when the Lock goes out of scope, even on exception.

View File

@ -1,98 +0,0 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.system.mutex;
import dsfml.system.common;
/**
* Provide portable implementation of Mutual Exclusion object.
*
* Uses CriticalSection on Windows and pthread mutexes on linux.
*/
final class Mutex : DSFMLObject
{
/**
* Constructor
*/
this()
{
super(sfMutex_Create());
}
override void dispose()
{
sfMutex_Destroy(m_ptr);
}
/**
* Lock the mutex
*
* Can be called multiples times, but each lock must be unlocked with unlock()
*/
void lock()
{
sfMutex_Lock(m_ptr);
}
/**
* Unlock the mutex
*/
void unlock()
{
sfMutex_Unlock(m_ptr);
}
private:
// External ====================================================================
extern (C)
{
typedef void* function() pf_sfMutex_Create;
typedef void function(void*) pf_sfMutex_Destroy;
typedef void function(void*) pf_sfMutex_Lock;
typedef void function(void*) pf_sfMutex_Unlock;
static pf_sfMutex_Create sfMutex_Create;
static pf_sfMutex_Destroy sfMutex_Destroy;
static pf_sfMutex_Lock sfMutex_Lock;
static pf_sfMutex_Unlock sfMutex_Unlock;
}
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-system-d");
else
DllLoader dll = DllLoader.load("csfml-system");
sfMutex_Create = cast(pf_sfMutex_Create)dll.getSymbol("sfMutex_Create");
sfMutex_Destroy = cast(pf_sfMutex_Destroy)dll.getSymbol("sfMutex_Destroy");
sfMutex_Lock = cast(pf_sfMutex_Lock)dll.getSymbol("sfMutex_Lock");
sfMutex_Unlock = cast(pf_sfMutex_Unlock)dll.getSymbol("sfMutex_Unlock");
}
}

View File

@ -1,134 +0,0 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.system.randomizer;
import dsfml.system.common;
/**
* Randomizer is an utility class for generating pseudo-random
* numbers
*
* Examples:
* -----------------------------------------------------------
* int randI = Randomizer.Random(1, 100);
* float randF = Randomizer.Random(1.0, 10.0)
* -----------------------------------------------------------
*/
class Randomizer
{
/**
* Set the seed for the generator. Using a known seed
* allows you to reproduce the same sequence of random number
*
* Params:
* seed = Number to use as the seed
*
*/
static void setSeed(uint seed)
{
sfRandom_SetSeed(seed);
}
/**
* Get the seed used to generate random numbers the generator.
*
* Returns:
* Current seed
*/
static uint getSeed()
{
return sfRandom_GetSeed();
}
/**
* Get a random float number in a given range
*
* Params:
* begin = Start of the range
* end = End of the range
* Returns:
* Random number in [Begin, End]
*/
static float random(float begin, float end)
{
return sfRandom_Float(begin, end);
}
/**
* Get a random integral number in a given range
*
* Params:
* begin = Start of the range
* end = End of the range
* Returns:
* Random number in [Begin, End]
*/
static int random(int begin, int end)
{
return sfRandom_Int(begin, end);
}
private:
/*
* Prevent instanciation
*/
this()
{
}
// External ====================================================================
extern (C)
{
typedef void function(uint) pf_sfRandom_SetSeed;
typedef uint function() pf_sfRandom_GetSeed;
typedef float function(float, float) pf_sfRandom_Float;
typedef int function(int, int) pf_sfRandom_Int;
static pf_sfRandom_SetSeed sfRandom_SetSeed;
static pf_sfRandom_GetSeed sfRandom_GetSeed;
static pf_sfRandom_Float sfRandom_Float;
static pf_sfRandom_Int sfRandom_Int;
}
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-system-d");
else
DllLoader dll = DllLoader.load("csfml-system");
sfRandom_SetSeed = cast(pf_sfRandom_SetSeed)dll.getSymbol("sfRandom_SetSeed");
sfRandom_GetSeed = cast(pf_sfRandom_GetSeed)dll.getSymbol("sfRandom_GetSeed");
sfRandom_Float = cast(pf_sfRandom_Float)dll.getSymbol("sfRandom_Float");
sfRandom_Int = cast(pf_sfRandom_Int)dll.getSymbol("sfRandom_Int");
}
}

View File

@ -1,58 +0,0 @@
/*
* DSFML - SFML Library wrapper for the D programming language.
* Copyright (C) 2008 Julien Dagorn (sirjulio13@gmail.com)
* Copyright (C) 2010 Andreas Hollandt
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
*/
module dsfml.system.sleep;
import dsfml.system.common;
extern(C)
{
typedef void function(float) pf_sfSleep;
private static const __gshared pf_sfSleep sfSleep;
}
static this()
{
debug
DllLoader dll = DllLoader.load("csfml-system-d");
else
DllLoader dll = DllLoader.load("csfml-system");
sfSleep = cast(pf_sfSleep)dll.getSymbol("sfSleep");
}
/**
* Make the current thread sleep for a given time
*
* Params:
* duration = Time to sleep, in seconds
*/
void sleep(float duration)
{
sfSleep(duration);
}