Index: src/hu/varadiistvan/scpl/.copyright
===================================================================
--- src/hu/varadiistvan/scpl/.copyright	(revision 1)
+++ src/hu/varadiistvan/scpl/.copyright	(revision 1)
@@ -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: src/hu/varadiistvan/scpl/.namespace
===================================================================
--- src/hu/varadiistvan/scpl/.namespace	(revision 1)
+++ src/hu/varadiistvan/scpl/.namespace	(revision 1)
@@ -0,0 +1,3 @@
+hu
+varadiistvan
+scpl
Index: src/hu/varadiistvan/scpl/.srcmessage
===================================================================
--- src/hu/varadiistvan/scpl/.srcmessage	(revision 1)
+++ src/hu/varadiistvan/scpl/.srcmessage	(revision 1)
@@ -0,0 +1,1 @@
+// This file is part of VSCPL, a simple cross-platform utility library
Index: src/hu/varadiistvan/scpl/Makefile.am
===================================================================
--- src/hu/varadiistvan/scpl/Makefile.am	(revision 0)
+++ src/hu/varadiistvan/scpl/Makefile.am	(revision 1)
@@ -0,0 +1,28 @@
+SUBDIRS=
+
+if TARGET_API_POSIX
+SUBDIRS+=_posix
+endif
+
+if TARGET_API_WIN32
+SUBDIRS+=_win32
+AM_LDFLAGS=-no-undefined
+endif
+
+lib_LTLIBRARIES=libvscpl.la
+
+libvscpl_la_SOURCES=\
+        dummy.cc
+
+if TARGET_API_POSIX
+libvscpl_la_LIBADD=_posix/libvscpl_posix.la
+endif
+
+if TARGET_API_WIN32
+libvscpl_la_LIBADD=_win32/libvscpl_win32.la
+endif
+
+include_vscpldir=$(includedir)/hu/varadiistvan/scpl
+include_vscpl_HEADERS=\
+        config.h                \
+        Thread.h
Index: src/hu/varadiistvan/scpl/Thread.h
===================================================================
--- src/hu/varadiistvan/scpl/Thread.h	(revision 1)
+++ src/hu/varadiistvan/scpl/Thread.h	(revision 1)
@@ -0,0 +1,122 @@
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_THREAD_H
+#define HU_VARADIISTVAN_SCPL_THREAD_H
+//------------------------------------------------------------------------------
+
+// The public interface of the Thread class common to all platforms
+#if 0
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A thread
+ */
+class Thread
+{
+public:
+    /**
+     * Sleep for the given number of milliseconds.
+     */
+    static void sleep(unsigned millis);
+
+public:
+    /**
+     * Construct the thread.
+     *
+     * @param detached if true, the thread will be created as a
+     * detached one, i.e. it can't be joined later on. The thread
+     * object will also be deleted when its run() function has
+     * finished.
+     */
+    Thread(bool detached = false);
+
+    /**
+     * Virtual destructor.
+     */
+    virtual ~Thread();
+
+    /**
+     * Start the thread.
+     *
+     * @return if the thread could be started
+     */
+    bool start();
+
+    /**
+     * Perform the thread's real operation. To be implemented in children
+     */
+    virtual void run() = 0;
+
+    /**
+     * Wait for the thread to quit.
+     */
+    void join();
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+#endif // 0, The public interface of the Thread class common to all platforms
+
+//------------------------------------------------------------------------------
+
+#include "config.h"
+
+//------------------------------------------------------------------------------
+
+#if TARGET_API_POSIX
+
+#include "_posix/Thread.h"
+
+//------------------------------------------------------------------------------
+
+#elif TARGET_API_WIN32 || TARGET_API_WIN64
+
+#include "_win32/Thread.h"
+
+//------------------------------------------------------------------------------
+
+#endif
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_THREAD_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/_posix/.copyright
===================================================================
--- src/hu/varadiistvan/scpl/_posix/.copyright	(revision 1)
+++ src/hu/varadiistvan/scpl/_posix/.copyright	(revision 1)
@@ -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: src/hu/varadiistvan/scpl/_posix/.namespace
===================================================================
--- src/hu/varadiistvan/scpl/_posix/.namespace	(revision 1)
+++ src/hu/varadiistvan/scpl/_posix/.namespace	(revision 1)
@@ -0,0 +1,3 @@
+hu
+varadiistvan
+scpl
Index: src/hu/varadiistvan/scpl/_posix/.srcmessage
===================================================================
--- src/hu/varadiistvan/scpl/_posix/.srcmessage	(revision 1)
+++ src/hu/varadiistvan/scpl/_posix/.srcmessage	(revision 1)
@@ -0,0 +1,1 @@
+// This file is part of VSCPL, a simple cross-platform utility library
Index: src/hu/varadiistvan/scpl/_posix/Makefile.am
===================================================================
--- src/hu/varadiistvan/scpl/_posix/Makefile.am	(revision 1)
+++ src/hu/varadiistvan/scpl/_posix/Makefile.am	(revision 1)
@@ -0,0 +1,8 @@
+noinst_LTLIBRARIES=libvscpl_posix.la
+
+libvscpl_posix_la_SOURCES =	\
+	Thread.cc
+
+include_vscpl_posixdir=$(includedir)/hu/varadiistvan/scpl/_posix
+include_vscpl_posix_HEADERS=\
+	Thread.h
Index: src/hu/varadiistvan/scpl/_posix/Thread.cc
===================================================================
--- src/hu/varadiistvan/scpl/_posix/Thread.cc	(revision 1)
+++ src/hu/varadiistvan/scpl/_posix/Thread.cc	(revision 1)
@@ -0,0 +1,66 @@
+// 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 "Thread.h"
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::Thread;
+
+//------------------------------------------------------------------------------
+
+void* Thread::threadFn(void* arg)
+{
+    Thread* thread = reinterpret_cast<Thread*>(arg);
+    thread->run();
+    if (thread->detached) delete thread;
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+bool Thread::start()
+{
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, detached ? PTHREAD_CREATE_DETACHED :
+                                PTHREAD_CREATE_JOINABLE);
+    bool isOK = pthread_create(&thread, &attr, &threadFn, this)>=0;
+    pthread_attr_destroy(&attr);
+    return isOK;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/_posix/Thread.h
===================================================================
--- src/hu/varadiistvan/scpl/_posix/Thread.h	(revision 1)
+++ src/hu/varadiistvan/scpl/_posix/Thread.h	(revision 1)
@@ -0,0 +1,138 @@
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_POSIX_THREAD_H
+#define HU_VARADIISTVAN_SCPL_POSIX_THREAD_H
+//------------------------------------------------------------------------------
+
+#include <pthread.h>
+#include <unistd.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A pthreads-based thread implementation.
+ */
+class Thread
+{
+public:
+    /**
+     * Sleep for the given number of milliseconds.
+     */
+    static void sleep(unsigned millis);
+
+private:
+    /**
+     * The thread-runner function.
+     */
+    static void* threadFn(void* arg);
+
+    /**
+     * Indicate if the thread is detached or not.
+     */
+    bool detached;
+
+    /**
+     * The posix thread handle.
+     */
+    pthread_t thread;
+
+public:
+    /**
+     * Construct the thread
+     */
+    Thread(bool detached = false);
+
+    /**
+     * Virtual destructor.
+     */
+    virtual ~Thread();
+
+    /**
+     * Start the thread.
+     *
+     * @return if the thread could be started
+     */
+    bool start();
+
+    /**
+     * Perform the thread's real operation.
+     */
+    virtual void run() = 0;
+
+    /**
+     * Wait for the thread to quit.
+     */
+    void join();
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline void Thread::sleep(unsigned millis)
+{
+    usleep(static_cast<useconds_t>(millis)*1000);
+}
+
+//------------------------------------------------------------------------------
+
+inline Thread::Thread(bool detached) :
+    detached(detached)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline Thread::~Thread()
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline void Thread::join()
+{
+    pthread_join(thread, 0);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_POSIX_THREAD_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/_win32/.copyright
===================================================================
--- src/hu/varadiistvan/scpl/_win32/.copyright	(revision 1)
+++ src/hu/varadiistvan/scpl/_win32/.copyright	(revision 1)
@@ -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: src/hu/varadiistvan/scpl/_win32/.namespace
===================================================================
--- src/hu/varadiistvan/scpl/_win32/.namespace	(revision 1)
+++ src/hu/varadiistvan/scpl/_win32/.namespace	(revision 1)
@@ -0,0 +1,3 @@
+hu
+varadiistvan
+scpl
Index: src/hu/varadiistvan/scpl/_win32/.srcmessage
===================================================================
--- src/hu/varadiistvan/scpl/_win32/.srcmessage	(revision 1)
+++ src/hu/varadiistvan/scpl/_win32/.srcmessage	(revision 1)
@@ -0,0 +1,1 @@
+// This file is part of VSCPL, a simple cross-platform utility library
Index: src/hu/varadiistvan/scpl/_win32/Makefile.am
===================================================================
--- src/hu/varadiistvan/scpl/_win32/Makefile.am	(revision 1)
+++ src/hu/varadiistvan/scpl/_win32/Makefile.am	(revision 1)
@@ -0,0 +1,8 @@
+noinst_LTLIBRARIES=libvscpl_win32.la
+
+libvscpl_win32_la_SOURCES =	\
+	Thread.cc
+
+include_win32_posixdir=$(includedir)/hu/varadiistvan/scpl/_win32
+include_win32_posix_HEADERS=\
+	Thread.h
Index: src/hu/varadiistvan/scpl/_win32/Thread.cc
===================================================================
--- src/hu/varadiistvan/scpl/_win32/Thread.cc	(revision 1)
+++ src/hu/varadiistvan/scpl/_win32/Thread.cc	(revision 1)
@@ -0,0 +1,56 @@
+// 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 "Thread.h"
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::Thread;
+
+//------------------------------------------------------------------------------
+
+DWORD Thread::threadFn(LPVOID arg)
+{
+    Thread* thread = reinterpret_cast<Thread*>(arg);
+
+    thread->run();
+
+    if (thread->detached) delete thread;
+
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/_win32/Thread.h
===================================================================
--- src/hu/varadiistvan/scpl/_win32/Thread.h	(revision 1)
+++ src/hu/varadiistvan/scpl/_win32/Thread.h	(revision 1)
@@ -0,0 +1,156 @@
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_WIN32_THREAD_H
+#define HU_VARADIISTVAN_SCPL_WIN32_THREAD_H
+//------------------------------------------------------------------------------
+
+#include <windows.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A Win32 API thread implementation.
+ */
+class Thread
+{
+public:
+    /**
+     * Sleep for the given number of milliseconds.
+     */
+    static void sleep(unsigned millis);
+
+private:
+    /**
+     * The thread-runner function.
+     */
+    static DWORD WINAPI threadFn(LPVOID arg);
+
+    /**
+     * Indicate if the thread is detached.
+     */
+    bool detached;
+
+    /**
+     * The thread handle.
+     */
+    HANDLE handle;
+
+public:
+    /**
+     * Construct the thread object.
+     */
+    Thread(bool detached = false);
+
+    /**
+     * Virtual destructor.
+     */
+    virtual ~Thread();
+
+    /**
+     * Start the thread.
+     *
+     * @return if the thread could be started
+     */
+    bool start();
+
+    /**
+     * Perform the thread's real operation.
+     */
+    virtual void run() = 0;
+
+    /**
+     * Wait for the thread to quit.
+     */
+    void join();
+
+    void release();
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline void Thread::sleep(unsigned millis)
+{
+    Sleep(millis);
+}
+
+//------------------------------------------------------------------------------
+
+inline Thread::Thread(bool detached) :
+    detached(detached),
+    handle(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline Thread::~Thread()
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline bool Thread::start()
+{
+    handle = CreateThread(0, 0, &threadFn, this, 0, 0);
+    bool isOK = handle!=0;
+    if (detached && handle!=0) {
+        CloseHandle(handle);
+        handle = 0;
+    }
+    return isOK;
+}
+
+//------------------------------------------------------------------------------
+
+inline void Thread::join()
+{
+    if (handle!=0) {
+        WaitForSingleObject(handle, INFINITE);
+        CloseHandle(handle);
+    }
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_WIN32_THREAD_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/config.h.in
===================================================================
--- src/hu/varadiistvan/scpl/config.h.in	(revision 0)
+++ src/hu/varadiistvan/scpl/config.h.in	(revision 1)
@@ -1,77 +1,10 @@
-/* src/hu/varadiistvan/scpl/config.h.in.  Generated from configure.ac by autoheader.  */
+// Define to 1, if the library is compiled for the POSIX API
+#define TARGET_API_POSIX @TARGET_API_POSIX@
 
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
+// Define to 1, if the library is compiled for the 32- or 64-bit
+// Win32 API
+#define TARGET_API_WIN32 @TARGET_API_WIN32@
 
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the <windows.h> header file. */
-#undef HAVE_WINDOWS_H
-
-/* Define to 1 if you have the <winsock2.h> header file. */
-#undef HAVE_WINSOCK2_H
-
-/* Define to the sub-directory in which libtool stores uninstalled libraries.
-   */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Define if the target is the POSIX API. */
-#undef TARGET_API_POSIX
-
-/* Define if the target is the Win32 API. */
-#undef TARGET_API_WIN32
-
-/* Define if the target is the 64-bit Win32 API. */
-#undef TARGET_API_WIN64
-
-/* Version number of package */
-#undef VERSION
+// Define to 1, if the library is compiled for the 64-bit
+// Win32 API
+#define TARGET_API_WIN64 @TARGET_API_WIN64@
