diff --git a/Makefile.am b/Makefile.am index a5a3dfcf..4e610c1b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -291,13 +291,6 @@ UTIL_FILES = \ tap.cpp \ tap.hpp \ tap.ipp \ - threads/barrier.hpp \ - threads/mutex.hpp \ - threads/condition.hpp \ - threads/semaphore.hpp \ - threads/spinlock.cpp \ - threads/spinlock.hpp \ - threads/thread.hpp \ time.cpp \ time.hpp \ tuple.cpp \ @@ -331,14 +324,6 @@ UTIL_FILES += \ library_posix.cpp \ posix/dir.hpp \ posix/dir.cpp \ - threads/barrier_posix.cpp \ - threads/condition_posix.cpp \ - threads/mutex_posix.cpp \ - threads/semaphore_posix.cpp \ - threads/spinlock_posix.cpp \ - threads/thread_posix.cpp \ - threads/thread_posix.hpp \ - threads/thread_posix.ipp \ time_posix.cpp endif @@ -349,10 +334,6 @@ UTIL_FILES += \ io_win32.cpp \ library_win32.hpp \ library_win32.cpp \ - threads/mutex_win32.cpp \ - threads/mutex_win32.hpp \ - threads/thread_win32.cpp \ - threads/thread_win32.hpp \ time_win32.cpp \ win32/registry.hpp \ win32/registry.cpp diff --git a/threads/barrier.hpp b/threads/barrier.hpp deleted file mode 100644 index 87786643..00000000 --- a/threads/barrier.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_BARRIER_HPP -#define __UTIL_THREADS_BARRIER_HPP - -#include - -namespace util { namespace threads { - class barrier { - public: - explicit barrier (unsigned count); - ~barrier (); - - void wait (void); - - private: - pthread_barrier_t m_id; - }; -} } - -#endif diff --git a/threads/barrier_posix.cpp b/threads/barrier_posix.cpp deleted file mode 100644 index 56fdbbc8..00000000 --- a/threads/barrier_posix.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "barrier.hpp" - -#include "except.hpp" - -using util::threads::barrier; - - -/////////////////////////////////////////////////////////////////////////////// -barrier::barrier (unsigned count) -{ - pthread_barrier_init (&m_id, nullptr, count); -} - - -//----------------------------------------------------------------------------- -barrier::~barrier () -{ - pthread_barrier_destroy (&m_id); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -barrier::wait (void) -{ - auto err = pthread_barrier_wait (&m_id); - errno_error::try_code (err); -} diff --git a/threads/condition.hpp b/threads/condition.hpp deleted file mode 100644 index e884cd29..00000000 --- a/threads/condition.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_CONDITION_HPP -#define __UTIL_THREADS_CONDITION_HPP - -#include "mutex.hpp" - -#include - -namespace util { namespace threads { - class condition { - public: - condition (); - ~condition (); - - void wait (mutex&); - void wait (mutex&, std::chrono::nanoseconds); - - void signal (void); - void broadcast (void); - - pthread_cond_t native (void); - - private: - pthread_cond_t m_id; - }; -} } - -#endif diff --git a/threads/condition_posix.cpp b/threads/condition_posix.cpp deleted file mode 100644 index 5900bf81..00000000 --- a/threads/condition_posix.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "condition.hpp" - -#include "except.hpp" - -using util::threads::condition; -using util::threads::mutex; - - -/////////////////////////////////////////////////////////////////////////////// -condition::condition () -{ - auto err = pthread_cond_init (&m_id, nullptr); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -condition::~condition () -{ - auto err = pthread_cond_destroy (&m_id); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -condition::signal (void) -{ - auto err = pthread_cond_signal (&m_id); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -void -condition::broadcast (void) -{ - auto err = pthread_cond_broadcast (&m_id); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -condition::wait (mutex &m) -{ - auto mutid = m.native (); - auto err = pthread_cond_wait (&m_id, &mutid); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -void -condition::wait (mutex &m, std::chrono::nanoseconds t) -{ - struct timespec abstime; - abstime.tv_sec = std::chrono::duration_cast (t).count (); - abstime.tv_nsec = std::chrono::duration_cast (t).count (); - - auto mutid = m.native (); - - auto err = pthread_cond_timedwait (&m_id, &mutid, &abstime); - errno_error::try_code (err); -} diff --git a/threads/mutex.hpp b/threads/mutex.hpp deleted file mode 100644 index 0cd8cab6..00000000 --- a/threads/mutex.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_MUTEX_HPP -#define __UTIL_THREADS_MUTEX_HPP - -#include - -namespace util { namespace threads { - class mutex { - public: - mutex (); - ~mutex (); - - void lock (void); - bool try_lock (void); - void unlock (void); - - pthread_mutex_t native (void); - - private: - pthread_mutex_t m_id; - }; -} } - -#endif diff --git a/threads/mutex_posix.cpp b/threads/mutex_posix.cpp deleted file mode 100644 index 1f6cae46..00000000 --- a/threads/mutex_posix.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "mutex.hpp" - -#include "../except.hpp" -#include "../debug.hpp" - -using util::threads::mutex; - - -/////////////////////////////////////////////////////////////////////////////// -mutex::mutex () -{ - auto err = pthread_mutex_init (&m_id, nullptr); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -mutex::~mutex () -{ - auto err = pthread_mutex_destroy (&m_id); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -mutex::lock (void) -{ - auto err = pthread_mutex_lock (&m_id); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -bool -mutex::try_lock (void) -{ - switch (auto err = pthread_mutex_trylock (&m_id)) { - case 0: return true; - case EBUSY: return false; - - default: - errno_error::throw_code (err); - } - - unreachable (); -} diff --git a/threads/mutex_win32.cpp b/threads/mutex_win32.cpp deleted file mode 100644 index 1be2fa1a..00000000 --- a/threads/mutex_win32.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "mutex_win32.hpp" - -#include "except.hpp" - -using util::threads::win32::mutex; - - -/////////////////////////////////////////////////////////////////////////////// -mutex::mutex (): - m_id (CreateMutex (nullptr, false, nullptr)) -{ ; } - - -/////////////////////////////////////////////////////////////////////////////// -bool -mutex::lock (void) -{ - switch (WaitForSingleObject (m_id, INFINITE)) { - case WAIT_OBJECT_0: - return true; - - case WAIT_FAILED: - win32_error::throw_code (); - default: - unreachable (); - } -} - - -//----------------------------------------------------------------------------- -bool -mutex::lock (std::chrono::nanoseconds ns) -{ - auto ms = std::chrono::duration_cast (ns).count (); - switch (WaitForSingleObject (m_id, ms)) { - case WAIT_OBJECT_0: - return true; - case WAIT_TIMEOUT: - return false; - - case WAIT_FAILED: - win32_error::throw_code (); - default: - unreachable (); - } -} - - -/////////////////////////////////////////////////////////////////////////////// -void -mutex::unlock (void) -{ - if (ReleaseMutex (m_id)) - win32_error::throw_code (); -} diff --git a/threads/mutex_win32.hpp b/threads/mutex_win32.hpp deleted file mode 100644 index c73aec04..00000000 --- a/threads/mutex_win32.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_MUTEX_WIN32_HPP -#define __UTIL_THREADS_MUTEX_WIN32_HPP - -#include "io.hpp" - -#include - -namespace util { namespace threads { namespace win32 { - class mutex { - public: - mutex (); - - bool lock (void); - bool lock (std::chrono::nanoseconds); - void unlock (void); - - handle& native (void); - - private: - handle m_id; - }; -} } } - -#endif - diff --git a/threads/semaphore.hpp b/threads/semaphore.hpp deleted file mode 100644 index 37510292..00000000 --- a/threads/semaphore.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_SEMAPHORE_HPP -#define __UTIL_THREADS_SEMAPHORE_HPP - -#include - -namespace util { namespace threads { - class semaphore { - public: - explicit semaphore (unsigned value = 0); - ~semaphore (); - - void wait (void); - bool try_wait (void); - void post (void); - - sem_t native (void); - - private: - sem_t m_id; - }; -} } - - -#endif diff --git a/threads/semaphore_posix.cpp b/threads/semaphore_posix.cpp deleted file mode 100644 index 0e83adf1..00000000 --- a/threads/semaphore_posix.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "semaphore.hpp" - -#include "debug.hpp" -#include "except.hpp" - -using util::threads::semaphore; - - -/////////////////////////////////////////////////////////////////////////////// -semaphore::semaphore (unsigned value) -{ - auto err = sem_init (&m_id, false, value); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -semaphore::~semaphore () -{ - auto err = sem_destroy (&m_id); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -semaphore::wait (void) -{ - auto err = sem_wait (&m_id); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -bool -semaphore::try_wait (void) -{ - switch (auto err = sem_wait (&m_id)) { - case 0: return true; - case EAGAIN: return false; - - default: - errno_error::throw_code (err); - } - - unreachable (); -} - - -//----------------------------------------------------------------------------- -void -semaphore::post (void) -{ - auto err = sem_post (&m_id); - errno_error::try_code (err); -} diff --git a/threads/spinlock.cpp b/threads/spinlock.cpp deleted file mode 100644 index 1888bdae..00000000 --- a/threads/spinlock.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "spinlock.hpp" diff --git a/threads/spinlock.hpp b/threads/spinlock.hpp deleted file mode 100644 index 5806e9e7..00000000 --- a/threads/spinlock.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_SPINLOCK_HPP -#define __UTIL_THREADS_SPINLOCK_HPP - -#include - -namespace util { namespace threads { - class spinlock { - public: - spinlock (); - ~spinlock (); - - void lock (void); - void unlock (void); - - pthread_spinlock_t native (void); - - private: - pthread_spinlock_t m_id; - }; -} } - -#endif diff --git a/threads/spinlock_posix.cpp b/threads/spinlock_posix.cpp deleted file mode 100644 index da2328e5..00000000 --- a/threads/spinlock_posix.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "spinlock.hpp" - -#include "except.hpp" - -using util::threads::spinlock; - - -/////////////////////////////////////////////////////////////////////////////// -spinlock::spinlock () -{ - auto err = pthread_spin_init (&m_id, PTHREAD_PROCESS_PRIVATE); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -spinlock::~spinlock () -{ - auto err = pthread_spin_destroy (&m_id); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -spinlock::lock (void) -{ - auto err = pthread_spin_lock (&m_id); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -void -spinlock::unlock (void) -{ - auto err = pthread_spin_unlock (&m_id); - errno_error::try_code (err); -} diff --git a/threads/thread.hpp b/threads/thread.hpp deleted file mode 100644 index fb0c49fe..00000000 --- a/threads/thread.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_THREAD_HPP -#define __UTIL_THREADS_THREAD_HPP - -#include "platform.hpp" - -#if defined(PLATFORM_LINUX) -#include "thread_posix.hpp" -#elif defined(PLATFORM_WIN32) -#include "thread_win32.hpp" -#else -#error "Unhandled platform" -#endif - -#endif diff --git a/threads/thread_posix.cpp b/threads/thread_posix.cpp deleted file mode 100644 index cf3095f3..00000000 --- a/threads/thread_posix.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "thread.hpp" - -#include "except.hpp" - -#include - -using util::threads::thread; - - -/////////////////////////////////////////////////////////////////////////////// -void -thread::join (void) -{ - auto err = pthread_join (m_id, nullptr); - errno_error::try_code (err); -} - - -//----------------------------------------------------------------------------- -void -thread::kill (void) -{ - auto err = pthread_cancel (m_id); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -void -thread::yield (void) -{ - auto err = pthread_yield (); - errno_error::try_code (err); -} - - -/////////////////////////////////////////////////////////////////////////////// -unsigned -thread::concurrency (void) -{ - auto val = sysconf (_SC_NPROCESSORS_ONLN); - if (val < 0) - errno_error::throw_code (); - - return val; -} - - - -/////////////////////////////////////////////////////////////////////////////// -// pthread entry point -void* -thread::dispatch (void *func) -{ - typedef decltype(thread::m_func) func_t; - (*reinterpret_cast (func)) (); - return nullptr; -} diff --git a/threads/thread_posix.hpp b/threads/thread_posix.hpp deleted file mode 100644 index 9dab4d00..00000000 --- a/threads/thread_posix.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_THREAD_POSIX_HPP -#define __UTIL_THREADS_THREAD_POSIX_HPP - -#include -#include - -namespace util { namespace threads { - class thread { - public: - template - thread (Func &&_func, Args &&..._args); - thread (thread&&); - ~thread (); - - thread (const thread&) = delete; - thread& operator= (const thread&) = delete; - - - void join (void); - void kill (void); - - static void yield (void); - static unsigned concurrency (void); - - pthread_t native (void); - - private: - static void* dispatch (void*); - - std::function m_func; - pthread_t m_id; - }; -} } - -#include "thread_posix.ipp" - -#endif - diff --git a/threads/thread_posix.ipp b/threads/thread_posix.ipp deleted file mode 100644 index 259383ad..00000000 --- a/threads/thread_posix.ipp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifdef __UTIL_THREAD_IPP -#error -#endif -#define __UTIL_THREAD_IPP - -#include "tuple.hpp" -#include "except.hpp" - - -/////////////////////////////////////////////////////////////////////////////// -template -util::threads::thread::thread (Func &&_func, Args&&..._args): - m_func ([ - func = std::forward (_func), - args = std::make_tuple (std::forward (_args)...) - ] (void) { - return tuple::call (func, args); - }) -{ - auto err = pthread_create (&m_id, nullptr, dispatch, &m_func); - errno_error::try_code (err); -} diff --git a/threads/thread_win32.cpp b/threads/thread_win32.cpp deleted file mode 100644 index 6be37f39..00000000 --- a/threads/thread_win32.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#include "thread_win32.hpp" - -#include - -using util::threads::win32::thread; - - -/////////////////////////////////////////////////////////////////////////////// -unsigned -thread::concurrency (void) -{ - SYSTEM_INFO info; - GetSystemInfo (&info); - return info.dwNumberOfProcessors; -} diff --git a/threads/thread_win32.hpp b/threads/thread_win32.hpp deleted file mode 100644 index e68f9397..00000000 --- a/threads/thread_win32.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Copyright 2015 Danny Robson - */ - -#ifndef __UTIL_THREADS_THREAD_WIN32_HPP -#define __UTIL_THREADS_THREAD_WIN32_HPP - -#include -#include - -#include "io.hpp" - -namespace util { namespace threads { inline namespace win32 { - class thread { - public: - template - thread (Func &&_func, Args &&..._args) { } - - thread (thread&&); - ~thread (); - - thread (const thread&) = delete; - thread& operator= (const thread&) = delete; - - void join (void); - void kill (void); - - static void yield (void); - static unsigned concurrency (void); - - handle native (void); - - private: - std::function m_func; - handle m_id; - }; -} } } - -#endif