delete unused files
This commit is contained in:
parent
0a3dcbd476
commit
0380027819
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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
|
||||
|
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
#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<ThreadWorker*> threads_;
|
||||
Mutex lock_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
#endif
|
||||
Loading…
Reference in New Issue