1
#ifndef _XMLRPCTHREAD_H_
2
#define _XMLRPCTHREAD_H_
4
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
7
# pragma warning(disable:4786) // identifier was truncated in debug info
12
//! An abstract class providing an interface for objects that can run in a separate thread.
13
class XmlRpcRunnable {
15
//! Code to be executed.
16
virtual void run() = 0;
17
}; // class XmlRpcRunnable
20
//! A simple platform-independent thread API implemented for posix and windows.
23
//! Construct a thread object. Not usable until setRunnable() has been called.
24
XmlRpcThread() : _runner(0), _pThread(0) {}
26
//! Construct a thread object.
27
XmlRpcThread(XmlRpcRunnable* runnable) : _runner(runnable), _pThread(0) {}
29
//! Destructor. Does not perform a join() (ie, the thread may continue to run).
32
//! Execute the run method of the runnable object in a separate thread.
33
//! Returns immediately in the calling thread.
36
//! Waits until the thread exits.
39
//! Access the runnable
40
XmlRpcRunnable* getRunnable() const { return _runner; }
43
void setRunnable(XmlRpcRunnable* r) { _runner = r; }
47
//! Start the runnable going in a thread
48
static unsigned int __stdcall runInThread(void* pThread);
50
//! Code to be executed
51
XmlRpcRunnable* _runner;
53
//! Native thread object
56
}; // class XmlRpcThread
60
#endif // _XMLRPCTHREAD_H_