git-svn-id: svn://db.shs.com.ru/pip@888 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2020-02-27 19:00:40 +00:00
parent 9b2be3333b
commit 1cda19ac64
3 changed files with 76 additions and 24 deletions

View File

@@ -32,7 +32,8 @@
class PIThread;
class PIIntrospectionThreads;
class PIP_EXPORT __PIThreadCollection {
class PIP_EXPORT __PIThreadCollection: public PIObject {
PIOBJECT(__PIThreadCollection)
public:
static __PIThreadCollection * instance();
void registerThread(PIThread * t);
@@ -40,9 +41,11 @@ public:
PIVector<PIThread * > threads() const;
void lock() {mutex.lock();}
void unlock() {mutex.unlock();}
void startedAuto(PIThread * t);
EVENT_HANDLER(void, stoppedAuto);
private:
PIVector<PIThread * > threads_;
mutable PIMutex mutex;
PIVector<PIThread * > threads_, auto_threads_;
mutable PIMutex mutex, auto_mutex;
};
@@ -155,8 +158,15 @@ public:
EVENT(started)
EVENT(stopped)
//! \brief Start event handler with name \"handler\" of object \"object\"
//! in separate thread with name \"name\"
//! and automatically delete it on function finish
static void runOnce(PIObject * object, const char * handler, const PIString & name = PIString());
#ifdef PIP_CXX11_SUPPORT
static PIThread * runOnce(std::function<void()> func);
//! \brief Start function \"func\" in separate thread with name \"name\"
//! and automatically delete it on function finish
static void runOnce(std::function<void()> func, const PIString & name = PIString());
#endif
//! \handlers