30.11.2013 - New PICollection namespace, Android support, my own PIVector implementation
This commit is contained in:
@@ -61,6 +61,20 @@
|
||||
* every reopen timeout if reopen enabled. Reopen timeout is set by \a setReopenTimeout(),
|
||||
* reopen enable is set by \a setReopenEnabled().
|
||||
*
|
||||
* \section PIIODevice_sec6 Configuration
|
||||
* This is virtual function \a configureDevice() which executes when \a configure()
|
||||
* executes. This function takes two arguments: "e_main" and "e_parent" as void*. There
|
||||
* are pointers to PIConfig::Entry entries of section "section" and their parent. If
|
||||
* there is no parent "e_parent" = 0. Function \a configure() set three parameters of
|
||||
* device: "reopenEnabled", "reopenTimeout" and "threadedReadBufferSize", then execute
|
||||
* function \a configureDevice().
|
||||
* \n Each ancestor of %PIIODevice reimlements \a configureDevice() function to be able
|
||||
* to be confured from configuration file. This parameters described at section
|
||||
* "Configurable parameters" in the class reference. Usage example:
|
||||
* \snippet piiodevice.cpp configure
|
||||
* Implement example:
|
||||
* \snippet piiodevice.cpp configureDevice
|
||||
*
|
||||
* \section PIIODevice_ex0 Example
|
||||
* \snippet piiodevice.cpp 0
|
||||
*/
|
||||
@@ -186,6 +200,21 @@ void PIIODevice::run() {
|
||||
}
|
||||
|
||||
|
||||
PIByteArray PIIODevice::readForTime(double timeout_ms) {
|
||||
PIByteArray str;
|
||||
if (timeout_ms <= 0.) return str;
|
||||
int ret;
|
||||
uchar td[threadedReadBufferSize()];
|
||||
timer.reset();
|
||||
while (timer.elapsed_m() < timeout_ms) {
|
||||
ret = read(td, threadedReadBufferSize());
|
||||
if (ret <= 0) msleep(1);
|
||||
else str.append(td, ret);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
ullong PIIODevice::writeThreaded(const PIByteArray & data) {
|
||||
write_thread.lock();
|
||||
write_queue.enqueue(PIPair<PIByteArray, ullong>(data, tri));
|
||||
|
||||
Reference in New Issue
Block a user