refactor: migrate MICRO_PIP to fine-grained feature flags
Replace monolithic MICRO_PIP/PIP_MICRO with granular flags: Feature flags (CMake options + platform auto-detection): - PIP_NO_FILESYSTEM, PIP_NO_THREADS, PIP_NO_SOCKET - PIP_NO_PROCESS, PIP_NO_DYNLIB, PIP_NO_FFT, PIP_NO_SERIAL Embedded optimization flag: - PIP_EMBEDDED (auto-set for Pico SDK and FreeRTOS) Controls buffer sizes, time stubs, terminal fallback, init stubs Platform blocks in CMakeLists.txt: - Pico SDK: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL; conditionally disables THREADS (no FreeRTOS) and SOCKET (no LWIP) - FreeRTOS: auto-disables FS, PROCESS, DYNLIB, FFT, SERIAL; conditionally disables SOCKET (no LWIP) - Android: auto-disables PROCESS, DYNLIB, FFT Updated 96 files across libs/, utils/, tests/, and CMakeLists.txt. Builds verified for Linux (547 tests pass) and Pico SDK (100%). Removed all MICRO_PIP and PIP_MICRO references (0 remaining).
This commit is contained in:
@@ -116,10 +116,6 @@
|
||||
//! \~russian Макрос объявлен когда PIP решил что система поддерживает локализацию
|
||||
# define HAS_LOCALE
|
||||
|
||||
//! \~english Macro is defined when PIP is building for embedded systems
|
||||
//! \~russian Макрос объявлен когда PIP собирается для встраиваемых систем
|
||||
# define MICRO_PIP
|
||||
|
||||
//! \~english Macro is defined when compiler is Visual Studio
|
||||
//! \~russian Макрос объявлен когда компилятор Visual Studio
|
||||
# define CC_VC
|
||||
@@ -168,7 +164,6 @@
|
||||
//! \~russian Макрос для подавления предупреждения компилятора о неиспользуемой переменной
|
||||
# define NO_UNUSED(x)
|
||||
|
||||
# undef MICRO_PIP
|
||||
# undef FREERTOS
|
||||
|
||||
#endif // DOXYGEN
|
||||
@@ -223,12 +218,10 @@ extern char ** environ;
|
||||
# define assertm(exp, msg) assert(((void)msg, exp))
|
||||
# endif
|
||||
|
||||
# ifdef MICRO_PIP
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# elif defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||
# if defined(__GXX_RTTI__) || defined(__RTTI__)
|
||||
# define __PIP_TYPENAME__(T) typeid(T).name()
|
||||
# else
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# define __PIP_TYPENAME__(T) "?"
|
||||
# endif
|
||||
|
||||
# ifdef CC_GCC
|
||||
@@ -298,17 +291,17 @@ typedef long long ssize_t;
|
||||
//! \~english Macro to declare private section, "export" is optional
|
||||
//! \~russian Макрос для объявления частной секции, "export" необязателен
|
||||
//! \~sa PRIVATE PRIVATEWB
|
||||
# define PRIVATE_DECLARATION(e) \
|
||||
struct __Private__; \
|
||||
friend struct __Private__; \
|
||||
struct e __PrivateInitializer__ { \
|
||||
__PrivateInitializer__(); \
|
||||
__PrivateInitializer__(const __PrivateInitializer__ & o); \
|
||||
~__PrivateInitializer__(); \
|
||||
__PrivateInitializer__ & operator=(const __PrivateInitializer__ & o); \
|
||||
__Private__ * p = nullptr; \
|
||||
}; \
|
||||
__PrivateInitializer__ __privateinitializer__;
|
||||
# define PRIVATE_DECLARATION(e) \
|
||||
struct __Private__; \
|
||||
friend struct __Private__; \
|
||||
struct e __PrivateInitializer__ { \
|
||||
__PrivateInitializer__(); \
|
||||
__PrivateInitializer__(const __PrivateInitializer__ & o); \
|
||||
~__PrivateInitializer__(); \
|
||||
__PrivateInitializer__ & operator=(const __PrivateInitializer__ & o); \
|
||||
__Private__ * p = nullptr; \
|
||||
}; \
|
||||
__PrivateInitializer__ __privateinitializer__;
|
||||
|
||||
//! \~english Macro to start definition of private section
|
||||
//! \~russian Макрос для начала реализации частной секции
|
||||
@@ -318,35 +311,31 @@ typedef long long ssize_t;
|
||||
//! \~russian Макрос для окончания реализации частной секции без инициализации
|
||||
//! \~sa PRIVATE_DEFINITION_END PRIVATE_DEFINITION_START PRIVATE_DEFINITION_INITIALIZE PRIVATE PRIVATEWB
|
||||
# define PRIVATE_DEFINITION_END_NO_INITIALIZE(c) \
|
||||
} \
|
||||
;
|
||||
} \
|
||||
;
|
||||
|
||||
//! \~english Macro to initialize private section
|
||||
//! \~russian Макрос для инициализации частной секции
|
||||
//! \~sa PRIVATE_DEFINITION_END PRIVATE_DEFINITION_START PRIVATE_DEFINITION_END_NO_INITIALIZE PRIVATE PRIVATEWB
|
||||
# define PRIVATE_DEFINITION_INITIALIZE(c) \
|
||||
c::__PrivateInitializer__::__PrivateInitializer__() { \
|
||||
p = new c::__Private__(); \
|
||||
} \
|
||||
c::__PrivateInitializer__::__PrivateInitializer__(const c::__PrivateInitializer__ &) { /*if (p) delete p;*/ \
|
||||
p = new c::__Private__(); \
|
||||
} \
|
||||
c::__PrivateInitializer__::~__PrivateInitializer__() { \
|
||||
piDeleteSafety(p); \
|
||||
} \
|
||||
c::__PrivateInitializer__ & c::__PrivateInitializer__::operator=(const c::__PrivateInitializer__ &) { \
|
||||
piDeleteSafety(p); \
|
||||
p = new c::__Private__(); \
|
||||
return *this; \
|
||||
}
|
||||
# define PRIVATE_DEFINITION_INITIALIZE(c) \
|
||||
c::__PrivateInitializer__::__PrivateInitializer__() { p = new c::__Private__(); } \
|
||||
c::__PrivateInitializer__::__PrivateInitializer__(const c::__PrivateInitializer__ &) { /*if (p) delete p;*/ \
|
||||
p = new c::__Private__(); \
|
||||
} \
|
||||
c::__PrivateInitializer__::~__PrivateInitializer__() { piDeleteSafety(p); } \
|
||||
c::__PrivateInitializer__ & c::__PrivateInitializer__::operator=(const c::__PrivateInitializer__ &) { \
|
||||
piDeleteSafety(p); \
|
||||
p = new c::__Private__(); \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
|
||||
//! \~english Macro to end definition of private section with initialization
|
||||
//! \~russian Макрос для окончания реализации частной секции с инициализацией
|
||||
//! \~sa PRIVATE_DEFINITION_END_NO_INITIALIZE PRIVATE_DEFINITION_START PRIVATE_DEFINITION_INITIALIZE PRIVATE PRIVATEWB
|
||||
# define PRIVATE_DEFINITION_END(c) \
|
||||
PRIVATE_DEFINITION_END_NO_INITIALIZE \
|
||||
(c) PRIVATE_DEFINITION_INITIALIZE(c)
|
||||
# define PRIVATE_DEFINITION_END(c) \
|
||||
PRIVATE_DEFINITION_END_NO_INITIALIZE \
|
||||
(c) PRIVATE_DEFINITION_INITIALIZE(c)
|
||||
|
||||
//! \~english Macro to access private section by pointer
|
||||
//! \~russian Макрос для доступа к частной секции
|
||||
@@ -362,9 +351,9 @@ typedef long long ssize_t;
|
||||
|
||||
//! \~english Macro to remove class copy availability
|
||||
//! \~russian Макрос для запрета копирования класса
|
||||
#define NO_COPY_CLASS(name) \
|
||||
name(const name &) = delete; \
|
||||
name & operator=(const name &) = delete;
|
||||
#define NO_COPY_CLASS(name) \
|
||||
name(const name &) = delete; \
|
||||
name & operator=(const name &) = delete;
|
||||
|
||||
//! \~english Counter macro for unique identifier generation
|
||||
//! \~russian Макрос счетчика для генерации уникальных идентификаторов
|
||||
@@ -377,34 +366,19 @@ typedef long long ssize_t;
|
||||
//! \~russian Макрос для начала статической инициализации
|
||||
//! \~sa STATIC_INITIALIZER_END
|
||||
#define STATIC_INITIALIZER_BEGIN \
|
||||
class { \
|
||||
class _Initializer_ { \
|
||||
public: \
|
||||
_Initializer_() {
|
||||
class { \
|
||||
class _Initializer_ { \
|
||||
public: \
|
||||
_Initializer_() {
|
||||
//! \~english Macro to end static initializer
|
||||
//! \~russian Макрос для окончания статической инициализации
|
||||
//! \~sa STATIC_INITIALIZER_BEGIN
|
||||
#define STATIC_INITIALIZER_END \
|
||||
} \
|
||||
} \
|
||||
_initializer_; \
|
||||
} \
|
||||
_PIP_ADD_COUNTER(_pip_initializer_);
|
||||
|
||||
|
||||
//! \~english Minimal sleep in milliseconds for internal PIP using
|
||||
//! \~russian Минимальное значание задержки в милисекундах для внутреннего использования в библиотеке PIP
|
||||
//! \~\details
|
||||
//! \~english Using in \a piMinSleep(), \a PIThread, \a PITimer::Pool. By default 1ms.
|
||||
//! \~russian Используется в \a piMinSleep(), \a PIThread, \a PITimer::Pool. По умолчанию равна 1мс.
|
||||
//! \~\sa PIP_MIN_MSLEEP
|
||||
#ifndef PIP_MIN_MSLEEP
|
||||
# ifndef MICRO_PIP
|
||||
# define PIP_MIN_MSLEEP 1.
|
||||
# else
|
||||
# define PIP_MIN_MSLEEP 10.
|
||||
# endif
|
||||
#endif
|
||||
} \
|
||||
} \
|
||||
_initializer_; \
|
||||
} \
|
||||
_PIP_ADD_COUNTER(_pip_initializer_);
|
||||
|
||||
|
||||
//! \~english Macro used for infinite loop
|
||||
@@ -430,4 +404,12 @@ typedef long long ssize_t;
|
||||
#define WAIT_FOREVER FOREVER piMinSleep();
|
||||
|
||||
|
||||
#ifndef PIP_MIN_MSLEEP
|
||||
# ifdef PIP_EMBEDDED
|
||||
# define PIP_MIN_MSLEEP 10.
|
||||
# else
|
||||
# define PIP_MIN_MSLEEP 1.
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif // PIBASE_MACROS_H
|
||||
|
||||
+28
-26
@@ -367,7 +367,7 @@ void PICout::stdoutPIString(const PIString & str, PICoutStdStream s) {
|
||||
#ifdef HAS_LOCALE
|
||||
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> utf8conv;
|
||||
getStdStream(s) << utf8conv.to_bytes((char16_t *)&(const_cast<PIString &>(str).front()),
|
||||
(char16_t *)&(const_cast<PIString &>(str).front()) + str.size());
|
||||
(char16_t *)&(const_cast<PIString &>(str).front()) + str.size());
|
||||
#else
|
||||
for (PIChar c: str)
|
||||
getStdWStream(s).put(c.toWChar());
|
||||
@@ -409,32 +409,32 @@ void PICout::writeChar(char c) {
|
||||
}
|
||||
|
||||
|
||||
#define PIINTCOUT(v) \
|
||||
{ \
|
||||
if (!actve_) return *this; \
|
||||
space(); \
|
||||
if (int_base_ == 10) { \
|
||||
if (buffer_) { \
|
||||
(*buffer_) += PIString::fromNumber(v); \
|
||||
} else { \
|
||||
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v); \
|
||||
} \
|
||||
} else \
|
||||
write(PIString::fromNumber(v, int_base_)); \
|
||||
return *this; \
|
||||
}
|
||||
#define PIINTCOUT(v) \
|
||||
{ \
|
||||
if (!actve_) return *this; \
|
||||
space(); \
|
||||
if (int_base_ == 10) { \
|
||||
if (buffer_) { \
|
||||
(*buffer_) += PIString::fromNumber(v); \
|
||||
} else { \
|
||||
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v); \
|
||||
} \
|
||||
} else \
|
||||
write(PIString::fromNumber(v, int_base_)); \
|
||||
return *this; \
|
||||
}
|
||||
|
||||
#define PIFLOATCOUT(v) \
|
||||
{ \
|
||||
if (buffer_) { \
|
||||
(*buffer_) += PIString::fromNumber(v, 'g'); \
|
||||
} else { \
|
||||
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g'); \
|
||||
} \
|
||||
} \
|
||||
return *this;
|
||||
#define PIFLOATCOUT(v) \
|
||||
{ \
|
||||
if (buffer_) { \
|
||||
(*buffer_) += PIString::fromNumber(v, 'g'); \
|
||||
} else { \
|
||||
if (isOutputDeviceActive(Console)) getStdStream(stream_) << (v); \
|
||||
if (isOutputDeviceActive(Buffer)) PICout::__string__() += PIString::fromNumber(v, 'g'); \
|
||||
} \
|
||||
} \
|
||||
return *this;
|
||||
|
||||
|
||||
PICout & PICout::operator<<(const PIString & v) {
|
||||
@@ -709,6 +709,7 @@ void PICout::applyFormat(PICoutFormat f) {
|
||||
}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
PIString PICout::getBuffer() {
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
PIString ret = PICout::__string__();
|
||||
@@ -728,6 +729,7 @@ void PICout::clearBuffer() {
|
||||
PIMutexLocker ml(PICout::__mutex__());
|
||||
PICout::__string__().clear();
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
|
||||
bool PICout::setOutputDevice(PICout::OutputDevice d, bool on) {
|
||||
|
||||
@@ -41,9 +41,9 @@ class PIString;
|
||||
class PIByteArray;
|
||||
template<typename P>
|
||||
class PIBinaryStream;
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef _PIP_INIT_STUB_
|
||||
class PIInit;
|
||||
#endif
|
||||
#endif // _PIP_INIT_STUB_
|
||||
class PIChar;
|
||||
class PICout;
|
||||
class PIWaitEvent;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include "piinit.h"
|
||||
|
||||
#include "piincludes_p.h"
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef _PIP_INIT_STUB_
|
||||
|
||||
# include "pidir.h"
|
||||
# include "piobject.h"
|
||||
@@ -251,7 +251,7 @@ PIInit::PIInit() {
|
||||
PIStringAscii("FreeBSD");
|
||||
# elif defined(FREERTOS)
|
||||
PIStringAscii("FreeRTOS");
|
||||
# elif defined(MICRO_PIP)
|
||||
# elif defined(_PIP_INIT_STUB_)
|
||||
PIStringAscii("MicroPIP");
|
||||
# else
|
||||
uns.sysname;
|
||||
@@ -395,4 +395,4 @@ __PIInit_Initializer__::~__PIInit_Initializer__() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // _PIP_INIT_STUB_
|
||||
|
||||
+11
-6
@@ -31,6 +31,11 @@
|
||||
|
||||
#include "pibase.h"
|
||||
|
||||
// PIInit stub: enabled for embedded or when core features are missing
|
||||
#if defined(PIP_EMBEDDED) || (defined(PIP_NO_THREADS) && defined(PIP_NO_FILESYSTEM))
|
||||
# define _PIP_INIT_STUB_
|
||||
#endif
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
|
||||
# include "piincludes.h"
|
||||
@@ -50,11 +55,11 @@ public:
|
||||
|
||||
static __PIInit_Initializer__ __piinit_initializer__;
|
||||
|
||||
#ifdef MICRO_PIP
|
||||
#ifndef PIINIT_MICRO_STUB_DEFINED
|
||||
#define PIINIT_MICRO_STUB_DEFINED
|
||||
# ifdef _PIP_INIT_STUB_
|
||||
# ifndef PIINIT_MICRO_STUB_DEFINED
|
||||
# define PIINIT_MICRO_STUB_DEFINED
|
||||
|
||||
int __PIInit_Initializer__::count_ = 0;
|
||||
int __PIInit_Initializer__::count_ = 0;
|
||||
PIInit * __PIInit_Initializer__::__instance__ = nullptr;
|
||||
|
||||
__PIInit_Initializer__::__PIInit_Initializer__() {
|
||||
@@ -71,8 +76,8 @@ __PIInit_Initializer__::~__PIInit_Initializer__() {
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
# endif
|
||||
# endif
|
||||
|
||||
|
||||
//! \~\ingroup Core
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "piconditionvar.h"
|
||||
#include "pithread.h"
|
||||
#include "pitime.h"
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
# include "pifile.h"
|
||||
# include "piiostream.h"
|
||||
# include "pisysteminfo.h"
|
||||
@@ -176,9 +176,13 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
|
||||
in_event_cnt = 0;
|
||||
setName(name);
|
||||
setDebug(true);
|
||||
#ifndef PIP_NO_THREADS
|
||||
mutexObjects().lock();
|
||||
#endif
|
||||
objects() << this;
|
||||
#ifndef PIP_NO_THREADS
|
||||
mutexObjects().unlock();
|
||||
#endif
|
||||
// piCout << "new" << this;
|
||||
}
|
||||
|
||||
@@ -186,9 +190,13 @@ PIObject::PIObject(const PIString & name): _signature_(__PIOBJECT_SIGNATURE__),
|
||||
PIObject::~PIObject() {
|
||||
in_event_cnt = 0;
|
||||
// piCout << "delete" << this;
|
||||
#ifndef PIP_NO_THREADS
|
||||
mutexObjects().lock();
|
||||
#endif
|
||||
objects().removeAll(this);
|
||||
#ifndef PIP_NO_THREADS
|
||||
mutexObjects().unlock();
|
||||
#endif
|
||||
deleted(this);
|
||||
piDisconnectAll();
|
||||
_signature_ = 0;
|
||||
@@ -464,7 +472,7 @@ void PIObject::piDisconnect(PIObject * src, const PIString & sig) {
|
||||
src->connections.remove(i);
|
||||
i--;
|
||||
if (dest) {
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(PIP_NO_THREADS)
|
||||
PIMutexLocker _mld(dest->mutex_connect, src != dest);
|
||||
#endif
|
||||
dest->updateConnectors();
|
||||
@@ -482,7 +490,7 @@ void PIObject::piDisconnectAll() {
|
||||
// piCout << "disconnect"<< src << o;
|
||||
if (!o || (o == this)) continue;
|
||||
if (!o->isPIObject()) continue;
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(MICRO_PIP)
|
||||
#if !defined(ANDROID) && !defined(MAC_OS) && !defined(PIP_NO_THREADS)
|
||||
PIMutexLocker _mld(o->mutex_connect, this != o);
|
||||
#endif
|
||||
PIVector<Connection> & oc(o->connections);
|
||||
@@ -547,6 +555,7 @@ PIMap<uint, PIObject::__MetaData> & PIObject::__meta_data() {
|
||||
}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
void PIObject::callQueuedEvents() {
|
||||
mutex_queue.lock();
|
||||
PIVector<__QueuedEvent> qe = events_queue;
|
||||
@@ -560,6 +569,7 @@ void PIObject::callQueuedEvents() {
|
||||
if (e.dest_o->thread_safe_) e.dest_o->mutex_.unlock();
|
||||
}
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
|
||||
//! \details
|
||||
@@ -570,9 +580,11 @@ void PIObject::callQueuedEvents() {
|
||||
//! При первом вызове стартует фоновый поток для удаления объектов.
|
||||
//! Каждый объект из очереди удаляется только когда выйдет из всех
|
||||
//! событий и обработок.
|
||||
#ifndef PIP_NO_THREADS
|
||||
void PIObject::deleteLater() {
|
||||
Deleter::instance()->post(this);
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
|
||||
bool PIObject::findSuitableMethodV(const PIString & method, int args, int & ret_args, PIObject::__MetaFunc & ret) {
|
||||
@@ -732,7 +744,7 @@ void PIObject::dump(const PIString & line_prefix) const {
|
||||
}
|
||||
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
void dumpApplication(bool with_objects) {
|
||||
PIMutexLocker _ml(PIObject::mutexObjects());
|
||||
// printf("dump application ...\n");
|
||||
@@ -835,7 +847,7 @@ bool PIObject::Connection::disconnect() const {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
PRIVATE_DEFINITION_START(PIObject::Deleter)
|
||||
PIThread thread;
|
||||
PIConditionVariable cond_var;
|
||||
@@ -899,3 +911,4 @@ void PIObject::Deleter::deleteObject(PIObject * o) {
|
||||
}
|
||||
// piCout << "[Deleter] delete" << (uintptr_t)o << "done";
|
||||
}
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
//! требует явного опустошения очереди через \a callQueuedEvents() или
|
||||
//! \a maybeCallQueuedEvents().
|
||||
class PIP_EXPORT PIObject {
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_INTROSPECTION
|
||||
friend class PIObjectManager;
|
||||
friend PIP_EXPORT void dumpApplication(bool);
|
||||
friend class PIIntrospection;
|
||||
@@ -461,7 +461,9 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
sender->eventBegin();
|
||||
i.dest_o->emitter_ = sender;
|
||||
@@ -469,7 +471,9 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
}
|
||||
}
|
||||
@@ -494,7 +498,9 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
sender->eventBegin();
|
||||
i.dest_o->emitter_ = sender;
|
||||
@@ -505,7 +511,9 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
}
|
||||
}
|
||||
@@ -530,7 +538,9 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
sender->eventBegin();
|
||||
i.dest_o->emitter_ = sender;
|
||||
@@ -542,7 +552,9 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
}
|
||||
}
|
||||
@@ -568,7 +580,9 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
sender->eventBegin();
|
||||
i.dest_o->emitter_ = sender;
|
||||
@@ -581,7 +595,9 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
}
|
||||
}
|
||||
@@ -613,7 +629,9 @@ public:
|
||||
i.performer->postQueuedEvent(__QueuedEvent(i.slot, i.dest, i.dest_o, sender, vl));
|
||||
} else {
|
||||
bool ts = sender->thread_safe_;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.lock();
|
||||
#endif
|
||||
i.dest_o->eventBegin();
|
||||
sender->eventBegin();
|
||||
i.dest_o->emitter_ = sender;
|
||||
@@ -627,7 +645,9 @@ public:
|
||||
sender->eventEnd();
|
||||
if (i.dest_o->isPIObject()) {
|
||||
i.dest_o->emitter_ = 0;
|
||||
#ifndef PIP_NO_THREADS
|
||||
if (ts) i.dest_o->mutex_.unlock();
|
||||
#endif
|
||||
i.dest_o->eventEnd();
|
||||
}
|
||||
}
|
||||
@@ -638,6 +658,7 @@ public:
|
||||
|
||||
//! \~english Returns the first live object with name "name", or \c nullptr.
|
||||
//! \~russian Возвращает первый живой объект с именем "name", либо \c nullptr.
|
||||
#ifndef PIP_NO_THREADS
|
||||
static PIObject * findByName(const PIString & name) {
|
||||
PIMutexLocker _ml(mutexObjects());
|
||||
for (auto * i: PIObject::objects()) {
|
||||
@@ -646,6 +667,7 @@ public:
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
//! \~english Returns whether this pointer still refers to a live %PIObject instance.
|
||||
//! \~russian Возвращает, указывает ли этот указатель на ещё существующий экземпляр %PIObject.
|
||||
@@ -653,6 +675,7 @@ public:
|
||||
|
||||
//! \~english Returns whether this object belongs to class "T" or one of its registered descendants.
|
||||
//! \~russian Возвращает, принадлежит ли этот объект классу "T" или одному из его зарегистрированных потомков.
|
||||
#ifndef PIP_NO_THREADS
|
||||
template<typename T>
|
||||
bool isTypeOf() const {
|
||||
if (!isPIObject()) return false;
|
||||
@@ -667,6 +690,7 @@ public:
|
||||
if (!isTypeOf<T>()) return (T *)nullptr;
|
||||
return (T *)this;
|
||||
}
|
||||
#endif
|
||||
|
||||
//! \~english Returns whether "o" points to a live %PIObject instance.
|
||||
//! \~russian Возвращает, указывает ли "o" на ещё существующий экземпляр %PIObject.
|
||||
@@ -796,6 +820,7 @@ private:
|
||||
PIVector<PIVariantSimple> values;
|
||||
};
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
class Deleter {
|
||||
public:
|
||||
Deleter();
|
||||
@@ -807,6 +832,7 @@ private:
|
||||
void deleteObject(PIObject * o);
|
||||
PRIVATE_DECLARATION(PIP_EXPORT)
|
||||
};
|
||||
#endif
|
||||
|
||||
bool findSuitableMethodV(const PIString & method, int args, int & ret_args, __MetaFunc & ret);
|
||||
PIVector<__MetaFunc> findEH(const PIString & name) const;
|
||||
@@ -830,13 +856,19 @@ private:
|
||||
PIMap<uint, PIVariant> properties_;
|
||||
PISet<PIObject *> connectors;
|
||||
PIVector<__QueuedEvent> events_queue;
|
||||
PIMutex mutex_, mutex_connect, mutex_queue;
|
||||
PIObject * emitter_;
|
||||
bool thread_safe_, proc_event_queue;
|
||||
std::atomic_int in_event_cnt;
|
||||
|
||||
#ifndef PIP_NO_THREADS
|
||||
PIMutex mutex_, mutex_connect, mutex_queue;
|
||||
bool thread_safe_, proc_event_queue;
|
||||
#else
|
||||
PIMutex mutex_, mutex_connect, mutex_queue;
|
||||
bool thread_safe_ = false, proc_event_queue = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
|
||||
//! \~english Dumps application-level %PIObject diagnostics.
|
||||
//! \~russian Выводит диагностическую информацию уровня приложения для %PIObject.
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "piwaitevent_p.h"
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
# ifdef WINDOWS
|
||||
// # ifdef _WIN32_WINNT
|
||||
// # undef _WIN32_WINNT
|
||||
@@ -154,4 +154,4 @@ void * PIWaitEvent::getEvent() const {
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIP_NO_THREADS
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#ifndef PIWAITEVENT_P_H
|
||||
#define PIWAITEVENT_P_H
|
||||
|
||||
#ifndef MICRO_PIP
|
||||
#ifndef PIP_NO_THREADS
|
||||
|
||||
# include "pibase.h"
|
||||
// clang-format off
|
||||
@@ -67,5 +67,5 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif // MICRO_PIP
|
||||
#endif // PIP_NO_THREADS
|
||||
#endif // PIWAITEVENT_P_H
|
||||
|
||||
Reference in New Issue
Block a user