From 0380027819a6c66cfec8bbea12b9f7c35797dea2 Mon Sep 17 00:00:00 2001 From: James Cherry Date: Sat, 4 Apr 2020 16:32:19 -0700 Subject: [PATCH] delete unused files --- util/Condition.cc | 58 ------------------------------------ util/Condition.hh | 41 ------------------------- util/ReadWriteLock.cc | 33 --------------------- util/ReadWriteLock.hh | 66 ----------------------------------------- util/Thread.cc | 51 ------------------------------- util/Thread.hh | 48 ------------------------------ util/ThreadException.cc | 38 ------------------------ util/ThreadException.hh | 41 ------------------------- util/ThreadPool.cc | 51 ------------------------------- util/ThreadPool.hh | 45 ---------------------------- 10 files changed, 472 deletions(-) delete mode 100644 util/Condition.cc delete mode 100644 util/Condition.hh delete mode 100644 util/ReadWriteLock.cc delete mode 100644 util/ReadWriteLock.hh delete mode 100644 util/Thread.cc delete mode 100644 util/Thread.hh delete mode 100644 util/ThreadException.cc delete mode 100644 util/ThreadException.hh delete mode 100644 util/ThreadPool.cc delete mode 100644 util/ThreadPool.hh diff --git a/util/Condition.cc b/util/Condition.cc deleted file mode 100644 index f1fefac6..00000000 --- a/util/Condition.cc +++ /dev/null @@ -1,58 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "Machine.hh" -#include "Condition.hh" -#include "ThreadException.hh" -#include "Mutex.hh" - -namespace sta { - -Condition::Condition() -{ - int error = pthread_cond_init(&condition_, NULL); - CheckThreadError(error); -} - -Condition::~Condition() -{ - pthread_cond_destroy(&condition_); -} - -void -Condition::signal() -{ - int error = pthread_cond_signal(&condition_); - CheckThreadError(error); -} - - -void -Condition::broadcast() -{ - int error = pthread_cond_broadcast(&condition_); - CheckThreadError(error); -} - - -void -Condition::wait(Mutex &mutex) -{ - int error = pthread_cond_wait(&condition_, &mutex.mutex_); - CheckThreadError(error); -} - -} // namespace diff --git a/util/Condition.hh b/util/Condition.hh deleted file mode 100644 index e0afcd86..00000000 --- a/util/Condition.hh +++ /dev/null @@ -1,41 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef STA_CONDITION_H -#define STA_CONDITION_H - -#include "Pthread.hh" - -namespace sta { - -class Mutex; - -// C++ wrapper/facade for pthread_cond_t. -class Condition -{ -public: - Condition(); - ~Condition(); - void signal(); - void broadcast(); - void wait(Mutex &mutex); - -private: - pthread_cond_t condition_; -}; - -} // namespace -#endif diff --git a/util/ReadWriteLock.cc b/util/ReadWriteLock.cc deleted file mode 100644 index b3b67335..00000000 --- a/util/ReadWriteLock.cc +++ /dev/null @@ -1,33 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "Machine.hh" -#include "ReadWriteLock.hh" - -namespace sta { - -ReadWriteLock::ReadWriteLock() -{ - int error = pthread_rwlock_init(&rw_lock_, NULL); - CheckThreadError(error); -} - -ReadWriteLock::~ReadWriteLock() -{ - pthread_rwlock_destroy(&rw_lock_); -} - -} // namespace diff --git a/util/ReadWriteLock.hh b/util/ReadWriteLock.hh deleted file mode 100644 index b4b20a8a..00000000 --- a/util/ReadWriteLock.hh +++ /dev/null @@ -1,66 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef STA_READ_WRITE_LOCK_H -#define STA_READ_WRITE_LOCK_H - -#include "DisallowCopyAssign.hh" -#include "Error.hh" -#include "Pthread.hh" -#include "Mutex.hh" -#include "Condition.hh" - -namespace sta { - -// C++ wrapper/facade for pthread_rwlock_t. -class ReadWriteLock -{ -public: - ReadWriteLock(); - ~ReadWriteLock(); - void readLock(); - void writeLock(); - void unlock(); - -private: - DISALLOW_COPY_AND_ASSIGN(ReadWriteLock); - - pthread_rwlock_t rw_lock_; -}; - -inline void -ReadWriteLock::readLock() -{ - int error = pthread_rwlock_rdlock(&rw_lock_); - CheckThreadError(error); -} - -inline void -ReadWriteLock::writeLock() -{ - int error = pthread_rwlock_wrlock(&rw_lock_); - CheckThreadError(error); -} - -inline void -ReadWriteLock::unlock() -{ - int error = pthread_rwlock_unlock(&rw_lock_); - CheckThreadError(error); -} - -} // namespace -#endif diff --git a/util/Thread.cc b/util/Thread.cc deleted file mode 100644 index 8c9f405f..00000000 --- a/util/Thread.cc +++ /dev/null @@ -1,51 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "Machine.hh" -#include "ThreadException.hh" -#include "ThreadWorker.hh" -#include "Thread.hh" - -namespace sta { - -ThreadPool Thread::pool_; - -Thread::Thread() : - worker_(NULL) -{ -} - -void -Thread::beginTask(ThreadFunc func, - void *arg) -{ - worker_ = pool_.pop(); - worker_->beginTask(func, arg); -} - -void -Thread::wait() -{ - worker_->wait(); -#if 0 - delete worker_; -#else - pool_.push(worker_); -#endif - worker_ = NULL; -} - -} // namespace diff --git a/util/Thread.hh b/util/Thread.hh deleted file mode 100644 index c107a8f1..00000000 --- a/util/Thread.hh +++ /dev/null @@ -1,48 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef STA_THREAD_H -#define STA_THREAD_H - -#include "DisallowCopyAssign.hh" -#include "ThreadWorker.hh" -#include "ThreadPool.hh" - -namespace sta { - -// Basic thread class implemented using a pool of threads, -// i.e., the threads are put to sleep when their task is done -// and they are re-cycled for the next task. -class Thread -{ -public: - Thread(); - // After calling start(), the caller must call wait() before - // destroying this object. - void beginTask(ThreadFunc func, - void *arg); - void wait(); - -private: - DISALLOW_COPY_AND_ASSIGN(Thread); - - ThreadWorker *worker_; - - static ThreadPool pool_; -}; - -} // namespace -#endif diff --git a/util/ThreadException.cc b/util/ThreadException.cc deleted file mode 100644 index a0cfb6e1..00000000 --- a/util/ThreadException.cc +++ /dev/null @@ -1,38 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "Machine.hh" -#include "StringUtil.hh" -#include "ThreadException.hh" - -namespace sta { - -ThreadException::ThreadException(const char *filename, - int line, - int error) : - StaExceptionLine(filename, line), - error_(error) -{ -} - -const char * -ThreadException::what() const throw() -{ - const char *msg = strerror(error_); - return stringPrintTmp("Thread error in %s:%d %s.", filename_, line_, msg); -} - -} diff --git a/util/ThreadException.hh b/util/ThreadException.hh deleted file mode 100644 index c5dafb57..00000000 --- a/util/ThreadException.hh +++ /dev/null @@ -1,41 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef STA_THREAD_EXCEPTION_H -#define STA_THREAD_EXCEPTION_H - -#include "Error.hh" - -namespace sta { - -class ThreadException : public StaExceptionLine -{ -public: - ThreadException(const char *filename, - int line, - int error); - virtual const char *what() const throw(); - -protected: - int error_; -}; - -#define CheckThreadError(error) \ - if (error != 0) \ - throw ThreadException(__FILE__, __LINE__, error) - -} // namespace -#endif diff --git a/util/ThreadPool.cc b/util/ThreadPool.cc deleted file mode 100644 index 6653afc5..00000000 --- a/util/ThreadPool.cc +++ /dev/null @@ -1,51 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#include "Machine.hh" -#include "ThreadWorker.hh" -#include "ThreadPool.hh" - -namespace sta { - -ThreadPool::~ThreadPool() -{ - threads_.deleteContentsClear(); -} - -ThreadWorker * -ThreadPool::pop() -{ - lock_.lock(); - if (!threads_.empty()) { - ThreadWorker *thread = threads_.back(); - threads_.pop_back(); - lock_.unlock(); - return thread; - } - lock_.unlock(); - // No threads in the pool, get a new one. - return new ThreadWorker; -} - -void -ThreadPool::push(ThreadWorker *thread) -{ - lock_.lock(); - threads_.push_back(thread); - lock_.unlock(); -} - -} // namespace diff --git a/util/ThreadPool.hh b/util/ThreadPool.hh deleted file mode 100644 index b923f9aa..00000000 --- a/util/ThreadPool.hh +++ /dev/null @@ -1,45 +0,0 @@ -// OpenSTA, Static Timing Analyzer -// Copyright (c) 2020, Parallax Software, Inc. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -#ifndef STA_THREAD_POOL_H -#define STA_THREAD_POOL_H - -#include "DisallowCopyAssign.hh" -#include "Vector.hh" -#include "Mutex.hh" - -namespace sta { - -class ThreadWorker; - -class ThreadPool -{ -public: - ThreadPool() {} - ~ThreadPool(); - // Create a new working thread if the pool is empty. - ThreadWorker *pop(); - void push(ThreadWorker *thread); - -private: - DISALLOW_COPY_AND_ASSIGN(ThreadPool); - - Vector threads_; - Mutex lock_; -}; - -} // namespace -#endif