Ой, это внутренние какие-то резервы иссякают! :( А ты ставишь после круглой скобочки пробел, та, что после названия функции и перед перечислением параметров? :)
// Protected Messages Queue template with stopable waiting locks. // M - message class, // C - STL messages container (deque by default) // MaxSize is required for effective resources control by Semaphores template
[Error: Irreparable invalid markup ('<class [...] m,>') in entry. Owner must fix manually. Raw contents below.]
// Protected Messages Queue template with stopable waiting locks. // M - message class, // C - STL messages container (deque<M> by default) // MaxSize is required for effective resources control by Semaphores template <class M, class C = std::deque< M > > class QueueT : private _BaseClassNotReplicatable { protected: // max size of buffer size_t m_SizeMax; // Max Size of buffer Semaphore m_sNotEmpty, m_sNotFull; CriticalSection m_csBuf; C m_Buf; Lock m_LockGet, m_LockPut; // Lockers: used Semaphores: m_sNotEmpty, m_sNotFull; public: //CTOR: creates buffer queue of max size. QueueT(size_t size_max = 1) : m_SizeMax(size_max), m_sNotEmpty(0), m_sNotFull(size_max), m_LockGet(m_sNotEmpty), m_LockPut(m_sNotFull) { }
//Threadsafe Get data from queue with timeout bool Get(M & m, ulong timeout = INFINITE_TIMEOUT) { if(!m_LockGet.Wait(timeout)) return false; m_csBuf.enter(); // protect buffer m = m_Buf.front(); m_Buf.pop_front(); m_csBuf.leave(); m_LockPut.Release(); return true; } //Threadsafe Put data in queue with timeout bool Put(const M & m, ulong timeout = INFINITE_TIMEOUT) { if(!m_LockPut.Wait(timeout)) return false; m_csBuf.enter(); // protect buffer m_Buf.push_back(m); m_csBuf.leave(); m_LockGet.Release(); return true; } void StopPut(void) { m_LockPut.Stop(); } void StopGet(void) { m_LockGet.Stop(); } // Threadsafe signal Abort flag, releasing all waiting threads... // Important: INFINITE_TIMEOUT can be used without deadlocks with this function: void Stop(void) { StopPut(); StopGet(); } }; // QueueT template
Так и я многим. Удивил! Хо! Зато я под Симбиан умею программировать, хотя, конечно, симафоры и критикалсекшн - это по высокому классу... Уважительно, ага...
no subject
Date: 2007-02-15 08:56 pm (UTC)no subject
no subject
Date: 2007-02-15 09:09 pm (UTC)у меня левое бедро болит! :)
no subject
Date: 2007-02-15 09:32 pm (UTC)no subject
Date: 2007-02-15 09:39 pm (UTC)А ты ставишь после круглой скобочки пробел, та, что после названия функции и перед перечислением параметров? :)
no subject
Date: 2007-02-15 09:41 pm (UTC)// M - message class,
// C - STL messages container (deque by default)
// MaxSize is required for effective resources control by Semaphores
template
// M - message class,
// C - STL messages container (deque<M> by default)
// MaxSize is required for effective resources control by Semaphores
template <class M, class C = std::deque< M > >
class QueueT : private _BaseClassNotReplicatable
{
protected:
// max size of buffer
size_t m_SizeMax; // Max Size of buffer
Semaphore m_sNotEmpty, m_sNotFull;
CriticalSection m_csBuf;
C m_Buf;
Lock m_LockGet, m_LockPut; // Lockers: used Semaphores: m_sNotEmpty, m_sNotFull;
public:
//CTOR: creates buffer queue of max size.
QueueT(size_t size_max = 1) : m_SizeMax(size_max), m_sNotEmpty(0), m_sNotFull(size_max),
m_LockGet(m_sNotEmpty), m_LockPut(m_sNotFull) { }
//Threadsafe Get data from queue with timeout
bool Get(M & m, ulong timeout = INFINITE_TIMEOUT) {
if(!m_LockGet.Wait(timeout)) return false;
m_csBuf.enter(); // protect buffer
m = m_Buf.front(); m_Buf.pop_front();
m_csBuf.leave();
m_LockPut.Release();
return true;
}
//Threadsafe Put data in queue with timeout
bool Put(const M & m, ulong timeout = INFINITE_TIMEOUT) {
if(!m_LockPut.Wait(timeout)) return false;
m_csBuf.enter(); // protect buffer
m_Buf.push_back(m);
m_csBuf.leave();
m_LockGet.Release();
return true;
}
void StopPut(void) { m_LockPut.Stop(); }
void StopGet(void) { m_LockGet.Stop(); }
// Threadsafe signal Abort flag, releasing all waiting threads...
// Important: INFINITE_TIMEOUT can be used without deadlocks with this function:
void Stop(void) { StopPut(); StopGet(); }
}; // QueueT template
no subject
Date: 2007-02-15 09:45 pm (UTC)А почему скобка фигурная на той же строке в начале функции, это я не люблю...
no subject
Date: 2007-02-15 09:47 pm (UTC)Все равно, ты мне нравишься :))
no subject
no subject
Date: 2007-02-15 09:51 pm (UTC)Зато я под Симбиан умею программировать, хотя, конечно, симафоры и критикалсекшн - это по высокому классу... Уважительно, ага...
no subject
Date: 2007-02-15 09:56 pm (UTC)no subject
Date: 2007-02-15 09:58 pm (UTC)no subject
Date: 2007-02-15 09:59 pm (UTC)Это самое главноe! ;)
no subject
Date: 2007-02-15 10:00 pm (UTC)