Index: test/.copyright
===================================================================
--- test/.copyright	(revision 2)
+++ test/.copyright	(revision 2)
@@ -0,0 +1,23 @@
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
Index: test/.copyright
===================================================================
--- test/.copyright	(revision 2)
+++ 	(revision )
@@ -1,23 +1,0 @@
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-
-// 1. Redistributions of source code must retain the above copyright notice, this
-//    list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation
-//    and/or other materials provided with the distribution.
-
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The views and conclusions contained in the software and documentation are those
-// of the authors and should not be interpreted as representing official policies,
-// either expressed or implied, of the FreeBSD Project.
Index: test/.srcmessage
===================================================================
--- test/.srcmessage	(revision 2)
+++ test/.srcmessage	(revision 2)
@@ -0,0 +1,1 @@
+// This file is part of VSCPL, a simple cross-platform utility library
Index: test/.srcmessage
===================================================================
--- test/.srcmessage	(revision 2)
+++ 	(revision )
@@ -1,1 +1,0 @@
-// This file is part of VSCPL, a simple cross-platform utility library
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 7)
+++ test/Makefile.am	(revision 7)
@@ -0,0 +1,19 @@
+INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src
+
+noinst_PROGRAMS=testthread testmutex testcondvar testevent
+
+LDADD=../src/hu/varadiistvan/scpl/libvscpl.la
+if TARGET_API_POSIX
+LDADD+=-lpthread
+endif
+if TARGET_API_WIN32
+AM_LDFLAGS=-static -static-libgcc -static-libstdc++
+endif
+
+testthread_SOURCES=testthread.cc
+
+testmutex_SOURCES=testmutex.cc
+
+testcondvar_SOURCES=testcondvar.cc
+
+testevent_SOURCES=testevent.cc
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 6)
+++ 	(revision )
@@ -1,17 +1,0 @@
-INCLUDES=-I$(top_srcdir)/src -I$(top_builddir)/src
-
-noinst_PROGRAMS=testthread testmutex testcondvar
-
-LDADD=../src/hu/varadiistvan/scpl/libvscpl.la
-if TARGET_API_POSIX
-LDADD+=-lpthread
-endif
-if TARGET_API_WIN32
-AM_LDFLAGS=-static -static-libgcc -static-libstdc++
-endif
-
-testthread_SOURCES=testthread.cc
-
-testmutex_SOURCES=testmutex.cc
-
-testcondvar_SOURCES=testcondvar.cc
Index: test/testcondvar.cc
===================================================================
--- test/testcondvar.cc	(revision 5)
+++ test/testcondvar.cc	(revision 5)
@@ -0,0 +1,184 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+//------------------------------------------------------------------------------
+
+#include <hu/varadiistvan/scpl/Thread.h>
+#include <hu/varadiistvan/scpl/Mutex.h>
+#include <hu/varadiistvan/scpl/CondVar.h>
+
+#include <cstdlib>
+#include <cstdio>
+#include <cassert>
+
+#include <signal.h>
+
+#include <sys/time.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::Thread;
+using hu::varadiistvan::scpl::Mutex;
+using hu::varadiistvan::scpl::CondVar;
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class Thread1 : public Thread
+{
+private:
+    char id;
+
+    Mutex& mutex;
+
+    CondVar& condVar;
+
+public:
+    Thread1(char id, Mutex& mutex, CondVar& condVar);
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline Thread1::Thread1(char id, Mutex& mutex, CondVar& condVar) :
+    id(id),
+    mutex(mutex),
+    condVar(condVar)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void Thread1::run()
+{
+    printf("Thread1[%c]::run: locking, and waiting on the condition\n", id);
+    mutex.lock();
+    condVar.wait(mutex);
+    printf("Thread1[%c]::run: condition received, waiting again\n", id);
+    condVar.wait(mutex);
+    printf("Thread1[%c]::run: condition received again, waiting with timeout\n", id);
+
+    bool result = condVar.wait(mutex, 5000);
+    printf("Thread1[%c]::run: waiting finished, %s\n", id,
+           result ? "received condition" : "timed out");
+    mutex.unlock();
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class Thread2 : public Thread
+{
+private:
+    Mutex& mutex;
+
+    CondVar& condVar;
+
+public:
+    Thread2(Mutex& mutex, CondVar& condVar);
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline Thread2::Thread2(Mutex& mutex, CondVar& condVar) :
+    mutex(mutex),
+    condVar(condVar)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void Thread2::run()
+{
+    printf("Thread2::run: sleeping\n");
+    sleep(2000);
+    printf("------------------------------------------------------------\n");
+
+    printf("Thread2::run: woke up, signalling condition variable\n");
+    condVar.signal();
+
+    printf("Thread2::run: sleeping...\n");
+    sleep(2000);
+    printf("------------------------------------------------------------\n");
+
+    printf("Thread2::run: woke up, broadcasting condition variable\n");
+    condVar.broadcast();
+
+    printf("Thread2::run: sleeping...\n");
+    sleep(2000);
+    printf("------------------------------------------------------------\n");
+
+    printf("Thread2::run: woke up, signalling condition variable\n");
+    condVar.signal();
+
+    printf("Thread2::run: sleeping...\n");
+    sleep(2000);
+    printf("------------------------------------------------------------\n");
+
+    printf("Thread2::run: woke up, signalling condition variable\n");
+    condVar.signal();
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    Mutex mutex;
+    CondVar condVar;
+
+    Thread1 thread1('A', mutex, condVar);
+    Thread1 thread1a('B', mutex, condVar);
+    Thread2 thread2(mutex, condVar);
+
+    printf("Starting threads\n");
+    thread1.start();
+    thread1a.start();
+    thread2.start();
+
+    printf("Waiting for thread1\n");
+    thread1.join();
+    thread1a.join();
+    printf("Waiting for thread2\n");
+    thread2.join();
+    printf("Both threads returned\n");
+
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: test/testcondvar.cc
===================================================================
--- test/testcondvar.cc	(revision 5)
+++ 	(revision )
@@ -1,184 +1,0 @@
-// Copyright (c) 2012 by István Váradi
-
-// This file is part of libxplcommon, a common utility library for
-// development related to X-Plane
-
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-
-// 1. Redistributions of source code must retain the above copyright notice, this
-//    list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation
-//    and/or other materials provided with the distribution.
-
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The views and conclusions contained in the software and documentation are those
-// of the authors and should not be interpreted as representing official policies,
-// either expressed or implied, of the FreeBSD Project.
-
-//------------------------------------------------------------------------------
-
-#include <hu/varadiistvan/scpl/Thread.h>
-#include <hu/varadiistvan/scpl/Mutex.h>
-#include <hu/varadiistvan/scpl/CondVar.h>
-
-#include <cstdlib>
-#include <cstdio>
-#include <cassert>
-
-#include <signal.h>
-
-#include <sys/time.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::Thread;
-using hu::varadiistvan::scpl::Mutex;
-using hu::varadiistvan::scpl::CondVar;
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-class Thread1 : public Thread
-{
-private:
-    char id;
-
-    Mutex& mutex;
-
-    CondVar& condVar;
-
-public:
-    Thread1(char id, Mutex& mutex, CondVar& condVar);
-
-    virtual void run();
-};
-
-//------------------------------------------------------------------------------
-
-inline Thread1::Thread1(char id, Mutex& mutex, CondVar& condVar) :
-    id(id),
-    mutex(mutex),
-    condVar(condVar)
-{
-}
-
-//------------------------------------------------------------------------------
-
-void Thread1::run()
-{
-    printf("Thread1[%c]::run: locking, and waiting on the condition\n", id);
-    mutex.lock();
-    condVar.wait(mutex);
-    printf("Thread1[%c]::run: condition received, waiting again\n", id);
-    condVar.wait(mutex);
-    printf("Thread1[%c]::run: condition received again, waiting with timeout\n", id);
-
-    bool result = condVar.wait(mutex, 5000);
-    printf("Thread1[%c]::run: waiting finished, %s\n", id,
-           result ? "received condition" : "timed out");
-    mutex.unlock();
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-class Thread2 : public Thread
-{
-private:
-    Mutex& mutex;
-
-    CondVar& condVar;
-
-public:
-    Thread2(Mutex& mutex, CondVar& condVar);
-
-    virtual void run();
-};
-
-//------------------------------------------------------------------------------
-
-inline Thread2::Thread2(Mutex& mutex, CondVar& condVar) :
-    mutex(mutex),
-    condVar(condVar)
-{
-}
-
-//------------------------------------------------------------------------------
-
-void Thread2::run()
-{
-    printf("Thread2::run: sleeping\n");
-    sleep(2000);
-    printf("------------------------------------------------------------\n");
-
-    printf("Thread2::run: woke up, signalling condition variable\n");
-    condVar.signal();
-
-    printf("Thread2::run: sleeping...\n");
-    sleep(2000);
-    printf("------------------------------------------------------------\n");
-
-    printf("Thread2::run: woke up, broadcasting condition variable\n");
-    condVar.broadcast();
-
-    printf("Thread2::run: sleeping...\n");
-    sleep(2000);
-    printf("------------------------------------------------------------\n");
-
-    printf("Thread2::run: woke up, signalling condition variable\n");
-    condVar.signal();
-
-    printf("Thread2::run: sleeping...\n");
-    sleep(2000);
-    printf("------------------------------------------------------------\n");
-
-    printf("Thread2::run: woke up, signalling condition variable\n");
-    condVar.signal();
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-int main()
-{
-    Mutex mutex;
-    CondVar condVar;
-
-    Thread1 thread1('A', mutex, condVar);
-    Thread1 thread1a('B', mutex, condVar);
-    Thread2 thread2(mutex, condVar);
-
-    printf("Starting threads\n");
-    thread1.start();
-    thread1a.start();
-    thread2.start();
-
-    printf("Waiting for thread1\n");
-    thread1.join();
-    thread1a.join();
-    printf("Waiting for thread2\n");
-    thread2.join();
-    printf("Both threads returned\n");
-
-    return 0;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: test/testevent.cc
===================================================================
--- test/testevent.cc	(revision 7)
+++ test/testevent.cc	(revision 7)
@@ -0,0 +1,194 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+//------------------------------------------------------------------------------
+
+#include <hu/varadiistvan/scpl/io/Waiter.h>
+#include <hu/varadiistvan/scpl/io/WaitableEvent.h>
+
+#include <hu/varadiistvan/scpl/Thread.h>
+
+#include <cstdio>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::Thread;
+using hu::varadiistvan::scpl::io::Waiter;
+using hu::varadiistvan::scpl::io::WaitableEvent;
+
+//------------------------------------------------------------------------------
+
+class ServerThread : public Thread
+{
+private:
+    Waiter waiter;
+
+    WaitableEvent event;
+
+public:
+    ServerThread();
+
+    WaitableEvent& getEvent();
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline ServerThread::ServerThread() :
+    event(&waiter)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline WaitableEvent& ServerThread::getEvent()
+{
+    return event;
+}
+
+//------------------------------------------------------------------------------
+
+void ServerThread::run()
+{
+    printf("ServerThread::run\n");
+    while(!event.check()) {
+        printf("ServerThread::run: waiting...\n");
+        waiter.wait();
+        printf("ServerThread::run: waiting done\n");
+    }
+    printf("ServerThread::run: finished\n");
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class BlockingServerThread : public Thread
+{
+private:
+    WaitableEvent event;
+
+public:
+    WaitableEvent& getEvent();
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline WaitableEvent& BlockingServerThread::getEvent()
+{
+    return event;
+}
+
+//------------------------------------------------------------------------------
+
+void BlockingServerThread::run()
+{
+    printf("BlockingServerThread::run: waiting...\n");
+    if (event.check()) {
+        printf("BlockingServerThread::run: waiting done\n");
+    } else {
+        printf("BlockingServerThread::run: waiting failed\n");
+    }
+    printf("BlockingServerThread::run: finished\n");
+}
+
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class ClientThread : public Thread
+{
+private:
+    WaitableEvent& event;
+
+public:
+    ClientThread(WaitableEvent& event);
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline ClientThread::ClientThread(WaitableEvent& event) :
+    event(event)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void ClientThread::run()
+{
+    printf("ClientThread::run: sleeping\n");
+    sleep(2000);
+    printf("ClientThread::run: firing event\n");
+    event.fire();
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+template <class Server> void runTest()
+{
+    Server serverThread;
+    ClientThread clientThread(serverThread.getEvent());
+
+    printf("Starting threads\n");
+    serverThread.start();
+    clientThread.start();
+
+    printf("Waiting for the client thread\n");
+    clientThread.join();
+    printf("Waiting for the server thread\n");
+    serverThread.join();
+    printf("Both threads returned\n");
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    printf("Running the event test with a non-blocking WaitableEvent\n\n");
+    runTest<ServerThread>();
+
+    printf("\n\nRunning the event test with a blocking WaitableEvent\n\n");
+    runTest<BlockingServerThread>();
+
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: test/testmutex.cc
===================================================================
--- test/testmutex.cc	(revision 4)
+++ test/testmutex.cc	(revision 4)
@@ -0,0 +1,162 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+//------------------------------------------------------------------------------
+
+#include <hu/varadiistvan/scpl/Thread.h>
+#include <hu/varadiistvan/scpl/Mutex.h>
+
+#include <cstdlib>
+#include <cstdio>
+#include <cassert>
+
+#include <signal.h>
+
+#include <sys/time.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::Thread;
+using hu::varadiistvan::scpl::Mutex;
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class Thread1 : public Thread
+{
+private:
+    Mutex& mutex;
+
+public:
+    Thread1(Mutex& mutex);
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline Thread1::Thread1(Mutex& mutex) :
+    mutex(mutex)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void Thread1::run()
+{
+    printf("Thread1::run: locking mutex\n");
+    mutex.lock();
+    printf("Thread1::run: locked mutex, sleeping...\n");
+
+    sleep(5000);
+
+    printf("Thread1::run: woke up, releasing mutex\n");
+    mutex.unlock();
+
+    printf("Thread1::run: released mutex, sleeping\n");
+
+    sleep(1000);
+
+    printf("Thread1::run: woke up, locking mutex\n");
+    mutex.lock();
+    printf("Thread1::run: locked mutex, releasing\n");
+    mutex.unlock();
+
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class Thread2 : public Thread
+{
+private:
+    Mutex& mutex;
+
+public:
+    Thread2(Mutex& mutex);
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline Thread2::Thread2(Mutex& mutex) :
+    mutex(mutex)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void Thread2::run()
+{
+    printf("Thread2::run: sleeping\n");
+    sleep(1000);
+
+    printf("Thread2::run: woke up, trying to lock mutex...\n");
+
+    while(!mutex.tryLock()) {
+        sleep(200);
+    }
+
+    printf("Thread2::run: locked mutex, sleeping...\n");
+    sleep(5000);
+    printf("Thread2::run: woke up, releasing mutex\n");
+    mutex.unlock();
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    Mutex mutex;
+
+    Thread1 thread1(mutex);
+    Thread2 thread2(mutex);
+
+    printf("Starting threads\n");
+    thread1.start();
+    thread2.start();
+
+
+    printf("Waiting for thread1\n");
+    thread1.join();
+    printf("Waiting for thread2\n");
+    thread2.join();
+    printf("Both threads returned\n");
+
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: test/testmutex.cc
===================================================================
--- test/testmutex.cc	(revision 4)
+++ 	(revision )
@@ -1,162 +1,0 @@
-// Copyright (c) 2012 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-
-// 1. Redistributions of source code must retain the above copyright notice, this
-//    list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation
-//    and/or other materials provided with the distribution.
-
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The views and conclusions contained in the software and documentation are those
-// of the authors and should not be interpreted as representing official policies,
-// either expressed or implied, of the FreeBSD Project.
-
-//------------------------------------------------------------------------------
-
-#include <hu/varadiistvan/scpl/Thread.h>
-#include <hu/varadiistvan/scpl/Mutex.h>
-
-#include <cstdlib>
-#include <cstdio>
-#include <cassert>
-
-#include <signal.h>
-
-#include <sys/time.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::Thread;
-using hu::varadiistvan::scpl::Mutex;
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-class Thread1 : public Thread
-{
-private:
-    Mutex& mutex;
-
-public:
-    Thread1(Mutex& mutex);
-
-    virtual void run();
-};
-
-//------------------------------------------------------------------------------
-
-inline Thread1::Thread1(Mutex& mutex) :
-    mutex(mutex)
-{
-}
-
-//------------------------------------------------------------------------------
-
-void Thread1::run()
-{
-    printf("Thread1::run: locking mutex\n");
-    mutex.lock();
-    printf("Thread1::run: locked mutex, sleeping...\n");
-
-    sleep(5000);
-
-    printf("Thread1::run: woke up, releasing mutex\n");
-    mutex.unlock();
-
-    printf("Thread1::run: released mutex, sleeping\n");
-
-    sleep(1000);
-
-    printf("Thread1::run: woke up, locking mutex\n");
-    mutex.lock();
-    printf("Thread1::run: locked mutex, releasing\n");
-    mutex.unlock();
-
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-class Thread2 : public Thread
-{
-private:
-    Mutex& mutex;
-
-public:
-    Thread2(Mutex& mutex);
-
-    virtual void run();
-};
-
-//------------------------------------------------------------------------------
-
-inline Thread2::Thread2(Mutex& mutex) :
-    mutex(mutex)
-{
-}
-
-//------------------------------------------------------------------------------
-
-void Thread2::run()
-{
-    printf("Thread2::run: sleeping\n");
-    sleep(1000);
-
-    printf("Thread2::run: woke up, trying to lock mutex...\n");
-
-    while(!mutex.tryLock()) {
-        sleep(200);
-    }
-
-    printf("Thread2::run: locked mutex, sleeping...\n");
-    sleep(5000);
-    printf("Thread2::run: woke up, releasing mutex\n");
-    mutex.unlock();
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-int main()
-{
-    Mutex mutex;
-
-    Thread1 thread1(mutex);
-    Thread2 thread2(mutex);
-
-    printf("Starting threads\n");
-    thread1.start();
-    thread2.start();
-
-
-    printf("Waiting for thread1\n");
-    thread1.join();
-    printf("Waiting for thread2\n");
-    thread2.join();
-    printf("Both threads returned\n");
-
-    return 0;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: test/testthread.cc
===================================================================
--- test/testthread.cc	(revision 2)
+++ test/testthread.cc	(revision 2)
@@ -0,0 +1,103 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+//------------------------------------------------------------------------------
+
+#include <hu/varadiistvan/scpl/Thread.h>
+
+#include <algorithm>
+
+#include <cstdio>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::Thread;
+
+using std::min;
+
+//------------------------------------------------------------------------------
+
+class TestThread : public Thread
+{
+private:
+    unsigned long id;
+
+public:
+    TestThread(unsigned long id);
+
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+inline TestThread::TestThread(unsigned long id) :
+    Thread(true),
+    id(id)
+{
+}
+
+//------------------------------------------------------------------------------
+
+void TestThread::run()
+{
+    printf("TestThread: id=%lu\n", id);
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    static const size_t numThreads = 1000;
+
+    TestThread** threads = new TestThread*[numThreads];
+
+    unsigned long id = 1;
+    while(true) {
+        for(size_t i = 0; i<numThreads; ++i) {
+            threads[i] = new TestThread(id++);
+            threads[i]->start();
+        }
+
+        Thread::sleep(2000);
+
+        // for(size_t i = 0; i<numThreads; ++i) {
+        //     delete threads[i];
+        // }
+    }
+
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: test/testthread.cc
===================================================================
--- test/testthread.cc	(revision 2)
+++ 	(revision )
@@ -1,103 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions are met:
-
-// 1. Redistributions of source code must retain the above copyright notice, this
-//    list of conditions and the following disclaimer.
-// 2. Redistributions in binary form must reproduce the above copyright notice,
-//    this list of conditions and the following disclaimer in the documentation
-//    and/or other materials provided with the distribution.
-
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
-// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// The views and conclusions contained in the software and documentation are those
-// of the authors and should not be interpreted as representing official policies,
-// either expressed or implied, of the FreeBSD Project.
-
-//------------------------------------------------------------------------------
-
-#include <hu/varadiistvan/scpl/Thread.h>
-
-#include <algorithm>
-
-#include <cstdio>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::Thread;
-
-using std::min;
-
-//------------------------------------------------------------------------------
-
-class TestThread : public Thread
-{
-private:
-    unsigned long id;
-
-public:
-    TestThread(unsigned long id);
-
-    virtual void run();
-};
-
-//------------------------------------------------------------------------------
-
-inline TestThread::TestThread(unsigned long id) :
-    Thread(true),
-    id(id)
-{
-}
-
-//------------------------------------------------------------------------------
-
-void TestThread::run()
-{
-    printf("TestThread: id=%lu\n", id);
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-int main()
-{
-    static const size_t numThreads = 1000;
-
-    TestThread** threads = new TestThread*[numThreads];
-
-    unsigned long id = 1;
-    while(true) {
-        for(size_t i = 0; i<numThreads; ++i) {
-            threads[i] = new TestThread(id++);
-            threads[i]->start();
-        }
-
-        Thread::sleep(2000);
-
-        // for(size_t i = 0; i<numThreads; ++i) {
-        //     delete threads[i];
-        // }
-    }
-
-    return 0;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
