mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-23 11:02:21 +03:00
lib: Remove unused threading functionality related to thread results
This commit is contained in:
parent
666460aced
commit
815e80ec4d
@ -235,15 +235,6 @@ public:
|
||||
*/
|
||||
virtual bool isExitedThread(ArchThread thread) = 0;
|
||||
|
||||
//! Returns the exit code of a thread
|
||||
/*!
|
||||
Waits indefinitely for \c thread to exit (if it hasn't yet) then
|
||||
returns the thread's exit code.
|
||||
|
||||
(Cancellation point)
|
||||
*/
|
||||
virtual void* getResultOfThread(ArchThread thread) = 0;
|
||||
|
||||
//! Returns an ID for a thread
|
||||
/*!
|
||||
Returns some ID number for \c thread. This is for logging purposes.
|
||||
|
@ -64,7 +64,6 @@ public:
|
||||
bool m_cancel;
|
||||
bool m_cancelling;
|
||||
bool m_exited;
|
||||
void* m_result;
|
||||
void* m_networkData;
|
||||
};
|
||||
|
||||
@ -76,7 +75,6 @@ ArchThreadImpl::ArchThreadImpl() :
|
||||
m_cancel(false),
|
||||
m_cancelling(false),
|
||||
m_exited(false),
|
||||
m_result(NULL),
|
||||
m_networkData(NULL)
|
||||
{
|
||||
// do nothing
|
||||
@ -526,13 +524,6 @@ ArchMultithreadPosix::isExitedThread(ArchThread thread)
|
||||
return thread->m_exited;
|
||||
}
|
||||
|
||||
void*
|
||||
ArchMultithreadPosix::getResultOfThread(ArchThread thread)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
return thread->m_result;
|
||||
}
|
||||
|
||||
IArchMultithread::ThreadID
|
||||
ArchMultithreadPosix::getIDOfThread(ArchThread thread)
|
||||
{
|
||||
@ -699,10 +690,8 @@ ArchMultithreadPosix::doThreadFunc(ArchThread thread)
|
||||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
}
|
||||
|
||||
void* result = NULL;
|
||||
try {
|
||||
// go
|
||||
result = (*thread->m_func)(thread->m_userData);
|
||||
(*thread->m_func)(thread->m_userData);
|
||||
}
|
||||
|
||||
catch (XThreadCancel&) {
|
||||
@ -721,7 +710,6 @@ ArchMultithreadPosix::doThreadFunc(ArchThread thread)
|
||||
// thread has exited
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_threadMutex);
|
||||
thread->m_result = result;
|
||||
thread->m_exited = true;
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,6 @@ public:
|
||||
virtual bool wait(ArchThread, double timeout);
|
||||
virtual bool isSameThread(ArchThread, ArchThread);
|
||||
virtual bool isExitedThread(ArchThread);
|
||||
virtual void* getResultOfThread(ArchThread);
|
||||
virtual ThreadID getIDOfThread(ArchThread);
|
||||
virtual void setSignalHandler(ESignal, SignalFunc, void*);
|
||||
virtual void raiseSignal(ESignal);
|
||||
|
@ -54,7 +54,6 @@ public:
|
||||
HANDLE m_cancel;
|
||||
bool m_cancelling;
|
||||
HANDLE m_exit;
|
||||
void* m_result;
|
||||
void* m_networkData;
|
||||
};
|
||||
|
||||
@ -65,7 +64,6 @@ ArchThreadImpl::ArchThreadImpl() :
|
||||
m_func(NULL),
|
||||
m_userData(NULL),
|
||||
m_cancelling(false),
|
||||
m_result(NULL),
|
||||
m_networkData(NULL)
|
||||
{
|
||||
m_exit = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||
@ -523,15 +521,6 @@ ArchMultithreadWindows::isExitedThread(ArchThread thread)
|
||||
return (WaitForSingleObject(thread->m_exit, 0) == WAIT_OBJECT_0);
|
||||
}
|
||||
|
||||
void*
|
||||
ArchMultithreadWindows::getResultOfThread(ArchThread thread)
|
||||
{
|
||||
lockMutex(m_threadMutex);
|
||||
void* result = thread->m_result;
|
||||
unlockMutex(m_threadMutex);
|
||||
return result;
|
||||
}
|
||||
|
||||
IArchMultithread::ThreadID
|
||||
ArchMultithreadWindows::getIDOfThread(ArchThread thread)
|
||||
{
|
||||
@ -678,10 +667,9 @@ ArchMultithreadWindows::doThreadFunc(ArchThread thread)
|
||||
lockMutex(m_threadMutex);
|
||||
unlockMutex(m_threadMutex);
|
||||
|
||||
void* result = NULL;
|
||||
try {
|
||||
// go
|
||||
result = (*thread->m_func)(thread->m_userData);
|
||||
(*thread->m_func)(thread->m_userData);
|
||||
}
|
||||
|
||||
catch (XThreadCancel&) {
|
||||
@ -695,9 +683,6 @@ ArchMultithreadWindows::doThreadFunc(ArchThread thread)
|
||||
}
|
||||
|
||||
// thread has exited
|
||||
lockMutex(m_threadMutex);
|
||||
thread->m_result = result;
|
||||
unlockMutex(m_threadMutex);
|
||||
SetEvent(thread->m_exit);
|
||||
|
||||
// done with thread
|
||||
|
@ -83,7 +83,6 @@ public:
|
||||
virtual bool wait(ArchThread, double timeout);
|
||||
virtual bool isSameThread(ArchThread, ArchThread);
|
||||
virtual bool isExitedThread(ArchThread);
|
||||
virtual void* getResultOfThread(ArchThread);
|
||||
virtual ThreadID getIDOfThread(ArchThread);
|
||||
virtual void setSignalHandler(ESignal, SignalFunc, void*);
|
||||
virtual void raiseSignal(ESignal);
|
||||
|
@ -69,7 +69,7 @@ Thread::operator=(const Thread& thread)
|
||||
void
|
||||
Thread::exit(void* result)
|
||||
{
|
||||
throw XThreadExit(result);
|
||||
throw XThreadExit();
|
||||
}
|
||||
|
||||
void
|
||||
@ -108,15 +108,6 @@ Thread::wait(double timeout) const
|
||||
return ARCH->wait(m_thread, timeout);
|
||||
}
|
||||
|
||||
void*
|
||||
Thread::getResult() const
|
||||
{
|
||||
if (wait())
|
||||
return ARCH->getResultOfThread(m_thread);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
IArchMultithread::ThreadID
|
||||
Thread::getID() const
|
||||
{
|
||||
@ -149,8 +140,6 @@ Thread::threadFunc(void* vjob)
|
||||
// get job
|
||||
IJob* job = static_cast<IJob*>(vjob);
|
||||
|
||||
// run job
|
||||
void* result = NULL;
|
||||
try {
|
||||
// go
|
||||
LOG((CLOG_DEBUG1 "thread 0x%08x entry", id));
|
||||
@ -163,10 +152,8 @@ Thread::threadFunc(void* vjob)
|
||||
delete job;
|
||||
throw;
|
||||
}
|
||||
catch (XThreadExit& e) {
|
||||
// client called exit()
|
||||
result = e.m_result;
|
||||
LOG((CLOG_DEBUG1 "caught exit on thread 0x%08x, result %p", id, result));
|
||||
catch (XThreadExit&) {
|
||||
LOG((CLOG_DEBUG1 "caught exit on thread 0x%08x", id));
|
||||
}
|
||||
catch (XBase& e) {
|
||||
LOG((CLOG_ERR "exception on thread 0x%08x: %s", id, e.what()));
|
||||
@ -182,6 +169,5 @@ Thread::threadFunc(void* vjob)
|
||||
// done with job
|
||||
delete job;
|
||||
|
||||
// return exit result
|
||||
return result;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -79,8 +79,7 @@ public:
|
||||
/*!
|
||||
Terminate the calling thread. This function does not return but
|
||||
the stack is unwound and automatic objects are destroyed, as if
|
||||
exit() threw an exception (which is, in fact, what it does). The
|
||||
argument is saved as the result returned by getResult(). If you
|
||||
exit() threw an exception (which is, in fact, what it does). If you
|
||||
have \c catch(...) blocks then you should add the following before
|
||||
each to avoid catching the exit:
|
||||
\code
|
||||
@ -167,16 +166,6 @@ public:
|
||||
*/
|
||||
bool wait(double timeout = -1.0) const;
|
||||
|
||||
//! Get the exit result
|
||||
/*!
|
||||
Returns the exit result. This does an implicit wait(). It returns
|
||||
NULL immediately if called by a thread on itself or on a thread that
|
||||
was cancelled.
|
||||
|
||||
(cancellation point)
|
||||
*/
|
||||
void* getResult() const;
|
||||
|
||||
//! Get the thread id
|
||||
/*!
|
||||
Returns an integer id for this thread. This id must not be used to
|
||||
|
@ -26,12 +26,4 @@ Thrown by Thread::exit() to exit a thread. Clients of Thread
|
||||
must not throw this type but must rethrow it if caught (by
|
||||
XThreadExit, XThread, or ...).
|
||||
*/
|
||||
class XThreadExit : public XThread {
|
||||
public:
|
||||
//! \c result is the result of the thread
|
||||
XThreadExit(void* result) : m_result(result) { }
|
||||
~XThreadExit() { }
|
||||
|
||||
public:
|
||||
void* m_result;
|
||||
};
|
||||
class XThreadExit : public XThread {};
|
||||
|
Loading…
Reference in New Issue
Block a user