doxygen @ tags replaced to \
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include "piconditionvar.h"
|
||||
|
||||
/**
|
||||
* @brief A Queue that supports operations that wait for the queue to become non-empty when retrieving an element, and
|
||||
* \brief A Queue that supports operations that wait for the queue to become non-empty when retrieving an element, and
|
||||
* wait for space to become available in the queue when storing an element.
|
||||
*/
|
||||
template <typename T>
|
||||
@@ -32,7 +32,7 @@ class PIBlockingQueue: private PIQueue<T> {
|
||||
public:
|
||||
|
||||
/**
|
||||
* @brief Constructor
|
||||
* \brief Constructor
|
||||
*/
|
||||
explicit inline PIBlockingQueue(size_t capacity = SIZE_MAX,
|
||||
PIConditionVariable* cond_var_add = new PIConditionVariable(),
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
: cond_var_add(cond_var_add), cond_var_rem(cond_var_rem), max_size(capacity) { }
|
||||
|
||||
/**
|
||||
* @brief Copy constructor. Initialize queue with copy of other queue elements. Not thread-safe for other queue.
|
||||
* \brief Copy constructor. Initialize queue with copy of other queue elements. Not thread-safe for other queue.
|
||||
*/
|
||||
explicit inline PIBlockingQueue(const PIDeque<T>& other) : cond_var_add(new PIConditionVariable()), cond_var_rem(new PIConditionVariable()) {
|
||||
mutex.lock();
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Thread-safe copy constructor. Initialize queue with copy of other queue elements.
|
||||
* \brief Thread-safe copy constructor. Initialize queue with copy of other queue elements.
|
||||
*/
|
||||
inline PIBlockingQueue(PIBlockingQueue<T> & other) : cond_var_add(new PIConditionVariable()), cond_var_rem(new PIConditionVariable()) {
|
||||
other.mutex.lock();
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts the specified element into this queue, waiting if necessary for space to become available.
|
||||
* \brief Inserts the specified element into this queue, waiting if necessary for space to become available.
|
||||
*
|
||||
* @param v the element to add
|
||||
*/
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
PIBlockingQueue<T> & enqueue(const T & v) {return put(v);}
|
||||
|
||||
/**
|
||||
* @brief Inserts the specified element at the end of this queue if it is possible to do so immediately without
|
||||
* \brief Inserts the specified element at the end of this queue if it is possible to do so immediately without
|
||||
* exceeding the queue's capacity, returning true upon success and false if this queue is full.
|
||||
*
|
||||
* @param v the element to add
|
||||
@@ -104,7 +104,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
|
||||
* \brief Retrieves and removes the head of this queue, waiting if necessary until an element becomes available.
|
||||
*
|
||||
* @return the head of this queue
|
||||
*/
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
T dequeue() {return take();}
|
||||
|
||||
/**
|
||||
* @brief Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an
|
||||
* \brief Retrieves and removes the head of this queue, waiting up to the specified wait time if necessary for an
|
||||
* element to become available.
|
||||
*
|
||||
* @param timeoutMs how long to wait before giving up, in milliseconds
|
||||
@@ -146,7 +146,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of elements that this queue can ideally (in the absence of memory or resource
|
||||
* \brief Returns the number of elements that this queue can ideally (in the absence of memory or resource
|
||||
* constraints) contains. This is always equal to the initial capacity of this queue less the current size of this queue.
|
||||
*
|
||||
* @return the capacity
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of additional elements that this queue can ideally (in the absence of memory or resource
|
||||
* \brief Returns the number of additional elements that this queue can ideally (in the absence of memory or resource
|
||||
* constraints) accept. This is always equal to the initial capacity of this queue less the current size of this queue.
|
||||
*
|
||||
* @return the remaining capacity
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the number of elements in this collection.
|
||||
* \brief Returns the number of elements in this collection.
|
||||
*/
|
||||
size_t size() {
|
||||
mutex.lock();
|
||||
@@ -183,7 +183,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Removes all available elements from this queue and adds them to other given queue.
|
||||
* \brief Removes all available elements from this queue and adds them to other given queue.
|
||||
*/
|
||||
size_t drainTo(PIDeque<T>& other, size_t maxCount = SIZE_MAX) {
|
||||
mutex.lock();
|
||||
@@ -194,7 +194,7 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Removes all available elements from this queue and adds them to other given queue.
|
||||
* \brief Removes all available elements from this queue and adds them to other given queue.
|
||||
*/
|
||||
size_t drainTo(PIBlockingQueue<T>& other, size_t maxCount = SIZE_MAX) {
|
||||
mutex.lock();
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* @brief A condition variable is an object able to block the calling thread until notified to resume.
|
||||
* \brief A condition variable is an object able to block the calling thread until notified to resume.
|
||||
*
|
||||
* It uses a PIMutex to lock the thread when one of its wait functions is called. The thread remains
|
||||
* blocked until woken up by another thread that calls a notification function on the same PIConditionVariable object.
|
||||
@@ -36,24 +36,24 @@ public:
|
||||
virtual ~PIConditionVariable();
|
||||
|
||||
/**
|
||||
* @brief Unblocks one of the threads currently waiting for this condition. If no threads are waiting, the function
|
||||
* \brief Unblocks one of the threads currently waiting for this condition. If no threads are waiting, the function
|
||||
* does nothing. If more than one, it is unspecified which of the threads is selected.
|
||||
*/
|
||||
void notifyOne();
|
||||
|
||||
/**
|
||||
* @brief Unblocks all threads currently waiting for this condition. If no threads are waiting, the function does
|
||||
* \brief Unblocks all threads currently waiting for this condition. If no threads are waiting, the function does
|
||||
* nothing.
|
||||
*/
|
||||
void notifyAll();
|
||||
|
||||
/**
|
||||
* @brief see wait(PIMutex &, const std::function<bool()>&)
|
||||
* \brief see wait(PIMutex &, const std::function<bool()>&)
|
||||
*/
|
||||
virtual void wait(PIMutex & lk);
|
||||
|
||||
/**
|
||||
* @brief Wait until notified
|
||||
* \brief Wait until notified
|
||||
*
|
||||
* The execution of the current thread (which shall have locked with lk method PIMutex::lock()) is blocked
|
||||
* until notified.
|
||||
@@ -79,12 +79,12 @@ public:
|
||||
virtual void wait(PIMutex& lk, const std::function<bool()>& condition);
|
||||
|
||||
/**
|
||||
* @brief see waitFor(PIMutex &, int, const std::function<bool()>&)
|
||||
* \brief see waitFor(PIMutex &, int, const std::function<bool()>&)
|
||||
*/
|
||||
virtual bool waitFor(PIMutex & lk, int timeoutMs);
|
||||
|
||||
/**
|
||||
* @brief Wait for timeout or until notified
|
||||
* \brief Wait for timeout or until notified
|
||||
*
|
||||
* The execution of the current thread (which shall have locked with lk method PIMutex::lock()) is blocked
|
||||
* during timeoutMs, or until notified (if the latter happens first).
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pigrabberbase.h
|
||||
* @brief Abstract class for create grabbers
|
||||
/*! \file pigrabberbase.h
|
||||
* \brief Abstract class for create grabbers
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/** \class PIMutex
|
||||
* @brief Mutex
|
||||
* \brief Mutex
|
||||
* \details
|
||||
* \section PIMutex_sec0 Synopsis
|
||||
* %PIMutex provides synchronization blocks between several threads.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pimutex.h
|
||||
* @brief PIMutex, PIMutexLocker
|
||||
/*! \file pimutex.h
|
||||
* \brief PIMutex, PIMutexLocker
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -38,16 +38,16 @@ public:
|
||||
~PIMutex();
|
||||
|
||||
|
||||
//! @brief Lock mutex
|
||||
//! \brief Lock mutex
|
||||
//! \details If mutex is unlocked it set to locked state and returns immediate.
|
||||
//! If mutex is already locked function blocks until mutex will be unlocked
|
||||
void lock();
|
||||
|
||||
//! @brief Unlock mutex
|
||||
//! \brief Unlock mutex
|
||||
//! \details In any case this function returns immediate
|
||||
void unlock() ;
|
||||
|
||||
//! @brief Try to lock mutex
|
||||
//! \brief Try to lock mutex
|
||||
//! \details If mutex is unlocked it set to locked state and returns "true" immediate.
|
||||
//! If mutex is already locked function returns immediate an returns "false"
|
||||
bool tryLock();
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//! @brief PIMutexLocker
|
||||
//! \brief PIMutexLocker
|
||||
//! \details Same as std::lock_guard<std::mutex>.
|
||||
//! When a PIMutexLocker object is created, it attempts to lock the mutex it is given, if "condition" true.
|
||||
//! When control leaves the scope in which the PIMutexLocker object was created,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pipipelinethread.h
|
||||
* @brief Class for create multihread pipeline
|
||||
/*! \file pipipelinethread.h
|
||||
* \brief Class for create multihread pipeline
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/** \class PISpinlock
|
||||
* @brief Spinlock
|
||||
* \brief Spinlock
|
||||
* \details
|
||||
* \section PISpinlock_sec0 Synopsis
|
||||
* %PISpinlock provides synchronization blocks between several threads.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pispinlock.h
|
||||
* @brief PISpinlock
|
||||
/*! \file pispinlock.h
|
||||
* \brief PISpinlock
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -39,12 +39,12 @@ public:
|
||||
~PISpinlock() {}
|
||||
|
||||
|
||||
//! @brief Lock spinlock
|
||||
//! \brief Lock spinlock
|
||||
//! \details If spinlock is unlocked it set to locked state and returns immediate.
|
||||
//! If spinlock is already locked function blocks until spinlock will be unlocked
|
||||
void lock() {while (flag.test_and_set(std::memory_order_acquire));}
|
||||
|
||||
//! @brief Unlock spinlock
|
||||
//! \brief Unlock spinlock
|
||||
//! \details In any case this function returns immediate
|
||||
void unlock() {flag.clear(std::memory_order_release);}
|
||||
|
||||
@@ -54,7 +54,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
//! @brief PISpinlockLocker
|
||||
//! \brief PISpinlockLocker
|
||||
//! \details
|
||||
//! When a PISpinlockLocker object is created, it attempts to lock the spinlock it is given, if "condition" true.
|
||||
//! When control leaves the scope in which the PISpinlockLocker object was created,
|
||||
|
||||
@@ -55,7 +55,7 @@ __THREAD_FUNC_RET__ thread_function_once(void * t) {((PIThread*)t)->__thread_fun
|
||||
#endif
|
||||
|
||||
/*! \class PIThread
|
||||
* @brief Thread class
|
||||
* \brief Thread class
|
||||
* \details This class allow you exec your code in separate thread.
|
||||
*
|
||||
* \section PIThread_sec0 Synopsis
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pithread.h
|
||||
* @brief Thread
|
||||
/*! \file pithread.h
|
||||
* \brief Thread
|
||||
*
|
||||
* This file declare thread class and some wait functions
|
||||
*/
|
||||
@@ -105,25 +105,25 @@ public:
|
||||
EVENT_HANDLER1(void, stop, bool, wait);
|
||||
EVENT_HANDLER0(void, terminate);
|
||||
|
||||
//! @brief Set common data passed to external function
|
||||
//! \brief Set common data passed to external function
|
||||
void setData(void * d) {data_ = d;}
|
||||
|
||||
//! @brief Set external function that will be executed after every \a run()
|
||||
//! \brief Set external function that will be executed after every \a run()
|
||||
void setSlot(ThreadFunc func) {ret_func = func;}
|
||||
|
||||
//! @brief Set external function that will be executed after every \a run()
|
||||
//! \brief Set external function that will be executed after every \a run()
|
||||
void setSlot(std::function<void()> func) {ret_func = [func](void*){func();};}
|
||||
|
||||
//! @brief Set priority of thread
|
||||
//! \brief Set priority of thread
|
||||
void setPriority(PIThread::Priority prior);
|
||||
|
||||
//! @brief Returns common data passed to external function
|
||||
//! \brief Returns common data passed to external function
|
||||
void * data() const {return data_;}
|
||||
|
||||
//! @brief Return priority of thread
|
||||
//! \brief Return priority of thread
|
||||
PIThread::Priority priority() const {return priority_;}
|
||||
|
||||
//! @brief Return \c true if thread is running
|
||||
//! \brief Return \c true if thread is running
|
||||
bool isRunning() const {return running_;}
|
||||
|
||||
bool isStopping() const {return running_ && terminating;}
|
||||
@@ -133,19 +133,19 @@ public:
|
||||
EVENT_HANDLER0(bool, waitForFinish) {return waitForFinish(-1);}
|
||||
EVENT_HANDLER1(bool, waitForFinish, int, timeout_msecs);
|
||||
|
||||
//! @brief Set necessity of lock every \a run with internal mutex
|
||||
//! \brief Set necessity of lock every \a run with internal mutex
|
||||
void needLockRun(bool need) {lockRun = need;}
|
||||
|
||||
//! @brief Lock internal mutex
|
||||
//! \brief Lock internal mutex
|
||||
EVENT_HANDLER0(void, lock) const {thread_mutex.lock();}
|
||||
|
||||
//! @brief Unlock internal mutex
|
||||
//! \brief Unlock internal mutex
|
||||
EVENT_HANDLER0(void, unlock) const {thread_mutex.unlock();}
|
||||
|
||||
//! @brief Returns internal mutex
|
||||
//! \brief Returns internal mutex
|
||||
PIMutex & mutex() const {return thread_mutex;}
|
||||
|
||||
//! @brief Returns thread ID
|
||||
//! \brief Returns thread ID
|
||||
llong tid() const {return tid_;}
|
||||
|
||||
void __thread_func__();
|
||||
@@ -154,12 +154,12 @@ public:
|
||||
EVENT(started)
|
||||
EVENT(stopped)
|
||||
|
||||
//! @brief Start event handler with name \"handler\" of object \"object\"
|
||||
//! \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());
|
||||
|
||||
//! @brief Start function \"func\" in separate thread with name \"name\"
|
||||
//! \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());
|
||||
|
||||
@@ -167,7 +167,7 @@ public:
|
||||
//! \{
|
||||
|
||||
/** \fn bool start(int timer_delay = -1)
|
||||
* @brief Start thread
|
||||
* \brief Start thread
|
||||
* \details Start execution of \a run() in internal loop with
|
||||
* "timer_delay" delay in milliseconds. If "timer_delay" <= 0
|
||||
* there is no delay in loop. Thread also exec external function
|
||||
@@ -176,58 +176,58 @@ public:
|
||||
* \return \c false if thread already started or can`t start thread */
|
||||
|
||||
/** \fn bool startOnce()
|
||||
* @brief Start thread without internal loop
|
||||
* \brief Start thread without internal loop
|
||||
* \details Start execution of \a run() once. Thread also exec
|
||||
* external function set by \a setSlot() if it`s not null
|
||||
*
|
||||
* \return \c false if thread already started or can`t start thread */
|
||||
|
||||
/** \fn bool startOnce(ThreadFunc func)
|
||||
* @brief Start thread without internal loop
|
||||
* \brief Start thread without internal loop
|
||||
* \details Overloaded function. Set external function "func" before start
|
||||
*
|
||||
* \return \c false if thread already started or can`t start thread */
|
||||
|
||||
/** \fn void stop(bool wait = false)
|
||||
* @brief Stop thread
|
||||
* \brief Stop thread
|
||||
* \details Stop execution of thread and wait for it finish
|
||||
* if "wait" is \c true. This function can block for infinite
|
||||
* time if "wait" is \c true and any of thread function is
|
||||
* busy forever */
|
||||
|
||||
/** \fn void terminate()
|
||||
* @brief Strongly stop thread
|
||||
* \brief Strongly stop thread
|
||||
* \details Stop execution of thread immediately */
|
||||
|
||||
/** \fn bool waitForStart(int timeout_msecs = -1)
|
||||
* @brief Wait for thread start
|
||||
* \brief Wait for thread start
|
||||
* \details This function block until thread start for "timeout_msecs"
|
||||
* or forever if "timeout_msecs" < 0
|
||||
*
|
||||
* \return \c false if timeout is exceeded */
|
||||
|
||||
/** \fn bool waitForFinish(int timeout_msecs = -1)
|
||||
* @brief Wait for thread finish
|
||||
* \brief Wait for thread finish
|
||||
* \details This function block until thread finish for "timeout_msecs"
|
||||
* or forever if "timeout_msecs" < 0
|
||||
*
|
||||
* \return \c false if timeout is exceeded */
|
||||
|
||||
//! \fn void lock()
|
||||
//! @brief Lock internal mutex
|
||||
//! \brief Lock internal mutex
|
||||
|
||||
//! \fn void unlock()
|
||||
//! @brief Unlock internal mutex
|
||||
//! \brief Unlock internal mutex
|
||||
|
||||
//! \}
|
||||
//! \events
|
||||
//! \{
|
||||
|
||||
//! \fn void started()
|
||||
//! @brief Raise on thread start
|
||||
//! \brief Raise on thread start
|
||||
|
||||
//! \fn void stopped()
|
||||
//! @brief Raise on thread stop
|
||||
//! \brief Raise on thread stop
|
||||
|
||||
//! \}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pithreadnotifier.h
|
||||
* @brief Class for simply notify and wait in different threads
|
||||
/*! \file pithreadnotifier.h
|
||||
* \brief Class for simply notify and wait in different threads
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "pithreadpoolexecutor.h"
|
||||
|
||||
/*! \class PIThreadPoolExecutor
|
||||
* @brief Thread pools address two different problems: they usually provide improved performance when executing large
|
||||
* \brief Thread pools address two different problems: they usually provide improved performance when executing large
|
||||
* numbers of asynchronous tasks, due to reduced per-task invocation overhead, and they provide a means of bounding and
|
||||
* managing the resources, including threads, consumed when executing a collection of tasks.
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
virtual ~PIThreadPoolExecutor();
|
||||
|
||||
/**
|
||||
* @brief Executes the given task sometime in the future. The task execute in an existing pooled thread. If the task
|
||||
* \brief Executes the given task sometime in the future. The task execute in an existing pooled thread. If the task
|
||||
* cannot be submitted for execution, either because this executor has been shutdown or because its capacity has been
|
||||
* reached.
|
||||
*
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
void shutdownNow();
|
||||
|
||||
/**
|
||||
* @brief Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be
|
||||
* \brief Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be
|
||||
* accepted. Invocation has no additional effect if already shut down. This method does not wait for previously
|
||||
* submitted tasks to complete execution. Use awaitTermination to do that.
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
|
||||
/*! \class PIThreadPoolLoop
|
||||
* @brief Thread class
|
||||
* \brief Thread class
|
||||
* \details This class allow you parallelize loop.
|
||||
*
|
||||
* \section PIThreadPoolLoop_sec0 Usage
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pithreadpoolloop.h
|
||||
* @brief Thread pool loop
|
||||
/*! \file pithreadpoolloop.h
|
||||
* \brief Thread pool loop
|
||||
*
|
||||
* This file declare thread class and some wait functions
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
|
||||
/*! \class PITimer
|
||||
* @brief Timer
|
||||
* \brief Timer
|
||||
*
|
||||
* \section PITimer_sec0 Synopsis
|
||||
* This class implements timer function. PIP timers supports 3 way to tick notify,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*! @file pitimer.h
|
||||
* @brief Timer
|
||||
/*! \file pitimer.h
|
||||
* \brief Timer
|
||||
*/
|
||||
/*
|
||||
PIP - Platform Independent Primitives
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
double interval() const {return interval_;}
|
||||
void setInterval(double i);
|
||||
|
||||
//! @brief Return \c true if thread is running
|
||||
//! \brief Return \c true if thread is running
|
||||
bool isRunning() const {return running_;}
|
||||
|
||||
bool isStopped() const {return !running_;}
|
||||
@@ -76,10 +76,10 @@ class PIP_EXPORT PITimer: public PIObject {
|
||||
public:
|
||||
NO_COPY_CLASS(PITimer)
|
||||
|
||||
//! @brief Constructs timer with PITimer::Thread implementation
|
||||
//! \brief Constructs timer with PITimer::Thread implementation
|
||||
explicit PITimer();
|
||||
|
||||
//! @brief Timer implementations
|
||||
//! \brief Timer implementations
|
||||
enum TimerImplementation {
|
||||
Thread /*! Timer works in his own thread. Intervals are measured by the system time */ = 0x01,
|
||||
ThreadRT /*! Using POSIX timer with SIGEV_THREAD notification. \attention Doesn`t support on Windows and Mac OS! */ = 0x02,
|
||||
@@ -87,34 +87,34 @@ public:
|
||||
* sequentially executes all timers. \attention Use this implementation with care! */ = 0x04
|
||||
};
|
||||
|
||||
//! @brief Constructs timer with "ti" implementation
|
||||
//! \brief Constructs timer with "ti" implementation
|
||||
explicit PITimer(TimerImplementation ti);
|
||||
|
||||
//! @brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
|
||||
//! \brief Constructs timer with "slot" slot void(void *,int), "data" data and "ti" implementation
|
||||
explicit PITimer(TimerEvent slot, void * data = 0, TimerImplementation ti = Thread);
|
||||
|
||||
//! @brief Constructs timer with "slot" slot void(), and "ti" implementation
|
||||
//! \brief Constructs timer with "slot" slot void(), and "ti" implementation
|
||||
explicit PITimer(std::function<void ()> slot, TimerImplementation ti = Thread);
|
||||
|
||||
//! @brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
|
||||
//! \brief Constructs timer with "slot" slot void(void *), "data" data and "ti" implementation
|
||||
explicit PITimer(std::function<void (void *)> slot, void * data, TimerImplementation ti = Thread);
|
||||
|
||||
virtual ~PITimer();
|
||||
|
||||
|
||||
//! @brief Returns timer implementation
|
||||
//! \brief Returns timer implementation
|
||||
PITimer::TimerImplementation implementation() const {return imp_mode;}
|
||||
|
||||
//! @brief Returns timer loop delay in milliseconds
|
||||
//! \brief Returns timer loop delay in milliseconds
|
||||
double interval() const;
|
||||
|
||||
//! @brief Set timer loop delay in milliseconds
|
||||
//! \brief Set timer loop delay in milliseconds
|
||||
EVENT_HANDLER1(void, setInterval, double, ms);
|
||||
|
||||
//! @brief Returns if timer is started
|
||||
//! \brief Returns if timer is started
|
||||
bool isRunning() const;
|
||||
|
||||
//! @brief Returns if timer is not started
|
||||
//! \brief Returns if timer is not started
|
||||
bool isStopped() const;
|
||||
|
||||
EVENT_HANDLER0(bool, start);
|
||||
@@ -123,22 +123,22 @@ public:
|
||||
EVENT_HANDLER0(bool, restart);
|
||||
|
||||
|
||||
/** @brief Start timer with \b interval() loop delay after \b delay_msecs delay.
|
||||
/** \brief Start timer with \b interval() loop delay after \b delay_msecs delay.
|
||||
* \details Timer wait \b delay_msecs milliseconds and then normally starts with
|
||||
* \b interval() loop delay. */
|
||||
void startDeferred(double delay_ms);
|
||||
|
||||
/** @brief Start timer with \b interval_msecs loop delay after \b delay_msecs delay.
|
||||
/** \brief Start timer with \b interval_msecs loop delay after \b delay_msecs delay.
|
||||
* \details Timer wait \b delay_msecs milliseconds and then normally starts with
|
||||
* \b interval_msecs loop delay. */
|
||||
void startDeferred(double interval_ms, double delay_ms);
|
||||
|
||||
/** @brief Start timer with \b interval() loop delay after \b start_datetime date and time.
|
||||
/** \brief Start timer with \b interval() loop delay after \b start_datetime date and time.
|
||||
* \details Timer wait until \b start_datetime and then normally starts with
|
||||
* \b interval() loop delay. */
|
||||
void startDeferred(PIDateTime start_datetime);
|
||||
|
||||
/** @brief Start timer with \b interval_msecs loop delay after \b start_datetime date and time.
|
||||
/** \brief Start timer with \b interval_msecs loop delay after \b start_datetime date and time.
|
||||
* \details Timer wait until \b start_datetime and then normally starts with
|
||||
* \b interval_msecs loop delay. */
|
||||
void startDeferred(double interval_ms, PIDateTime start_datetime);
|
||||
@@ -148,43 +148,43 @@ public:
|
||||
bool waitForFinish() {return waitForFinish(-1);}
|
||||
bool waitForFinish(int timeout_msecs);
|
||||
|
||||
//! @brief Set custom data
|
||||
//! \brief Set custom data
|
||||
void setData(void * data_) {data_t = data_;}
|
||||
|
||||
//! @brief Set timer tick function
|
||||
//! \brief Set timer tick function
|
||||
void setSlot(TimerEvent slot) {ret_func = slot;}
|
||||
|
||||
//! @brief Set timer tick function
|
||||
//! \brief Set timer tick function
|
||||
void setSlot(std::function<void ()> slot) {ret_func = [slot](void *, int){slot();};}
|
||||
|
||||
//! @brief Set timer tick function
|
||||
//! \brief Set timer tick function
|
||||
void setSlot(std::function<void (void *)> slot) {ret_func = [slot](void *d, int){slot(d);};}
|
||||
|
||||
//! @brief Returns common data passed to tick functions
|
||||
//! \brief Returns common data passed to tick functions
|
||||
void * data() const {return data_t;}
|
||||
|
||||
void needLockRun(bool need) {lockRun = need;}
|
||||
EVENT_HANDLER0(void, lock) {mutex_.lock();}
|
||||
EVENT_HANDLER0(void, unlock) {mutex_.unlock();}
|
||||
|
||||
//! @brief Returns if timer should exec \a maybeCallQueuedEvents() at every tick.
|
||||
//! \brief Returns if timer should exec \a maybeCallQueuedEvents() at every tick.
|
||||
//! By default \b true
|
||||
bool isCallQueuedEvents() const {return callEvents;}
|
||||
|
||||
//! @brief If set timer exec \a maybeCallQueuedEvents() at every tick.
|
||||
//! \brief If set timer exec \a maybeCallQueuedEvents() at every tick.
|
||||
//! By default \b true
|
||||
void setCallQueuedEvents(bool yes) {callEvents = yes;}
|
||||
|
||||
//! @brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
void addDelimiter(int delim, TimerEvent slot = 0) {delims << Delimiter(slot, delim);}
|
||||
|
||||
//! @brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
void addDelimiter(int delim, std::function<void ()> slot) {delims << Delimiter([slot](void *, int){slot();}, delim);}
|
||||
|
||||
//! @brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
//! \brief Add frequency delimiter \b delim with optional delimiter slot \b slot.
|
||||
void addDelimiter(int delim, std::function<void (void *)> slot) {delims << Delimiter([slot](void *d, int){slot(d);}, delim);}
|
||||
|
||||
//! @brief Remove all frequency delimiters \b delim.
|
||||
//! \brief Remove all frequency delimiters \b delim.
|
||||
void removeDelimiter(int delim) {for (int i = 0; i < delims.size_s(); ++i) if (delims[i].delim == delim) {delims.remove(i); i--;}}
|
||||
|
||||
EVENT_HANDLER0(void, clearDelimiters) {delims.clear();}
|
||||
@@ -195,30 +195,30 @@ public:
|
||||
//! \{
|
||||
|
||||
/** \fn bool start()
|
||||
* @brief Start timer with \a interval() loop delay
|
||||
* \brief Start timer with \a interval() loop delay
|
||||
* \details Start execution of timer functions with frequency = 1 / msecs Hz. */
|
||||
|
||||
/** \fn bool start(double msecs)
|
||||
* @brief Start timer with \b msecs loop delay
|
||||
* \brief Start timer with \b msecs loop delay
|
||||
* \details Start execution of timer functions with frequency = 1. / msecs Hz.
|
||||
* Instead of \a start(int msecs) function this variant allow start timer
|
||||
* with frequencies more than 1 kHz */
|
||||
|
||||
//! \fn bool restart()
|
||||
//! @brief Stop and start timer with \a interval() loop delay
|
||||
//! \brief Stop and start timer with \a interval() loop delay
|
||||
|
||||
//! \fn bool stop(bool wait = true)
|
||||
//! @brief Stop timer and wait for it finish if "wait"
|
||||
//! \brief Stop timer and wait for it finish if "wait"
|
||||
|
||||
//! \fn void clearDelimiters()
|
||||
//! @brief Remove all frequency delimiters
|
||||
//! \brief Remove all frequency delimiters
|
||||
|
||||
//! \}
|
||||
//! \events
|
||||
//! \{
|
||||
|
||||
/** \fn void tickEvent(void * data, int delimiter)
|
||||
* @brief Raise on timer tick
|
||||
* \brief Raise on timer tick
|
||||
* \details \b Data can be set with function \a setData(void * data) or from constructor.
|
||||
* \b Delimiter is frequency delimiter, 1 for main loop. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user