My Project
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
LibThread::SingularChannel Class Reference

Public Member Functions

 SingularChannel ()
 
virtual ~SingularChannel ()
 
void send (string item)
 
string receive ()
 
long count ()
 
- Public Member Functions inherited from LibThread::SharedObject
 SharedObject ()
 
virtual ~SharedObject ()
 
void set_type (int type_init)
 
int get_type ()
 
void set_name (std::string &name_init)
 
void set_name (const char *s)
 
std::string & get_name ()
 
void incref (int by=1)
 
long decref ()
 
long getref ()
 
virtual BOOLEAN op2 (int op, leftv res, leftv a1, leftv a2)
 
virtual BOOLEAN op3 (int op, leftv res, leftv a1, leftv a2, leftv a3)
 

Private Attributes

queue< string > q
 
Lock lock
 
ConditionVariable cond
 

Detailed Description

Definition at line 397 of file shared.cc.

Constructor & Destructor Documentation

◆ SingularChannel()

LibThread::SingularChannel::SingularChannel ( )
inline

Definition at line 403 of file shared.cc.

◆ ~SingularChannel()

virtual LibThread::SingularChannel::~SingularChannel ( )
inlinevirtual

Definition at line 404 of file shared.cc.

404{ }

Member Function Documentation

◆ count()

long LibThread::SingularChannel::count ( )
inline

Definition at line 423 of file shared.cc.

423 {
424 lock.lock();
425 long result = q.size();
426 lock.unlock();
427 return result;
428 }
queue< string > q
Definition: shared.cc:399
void lock()
Definition: thread.h:46
void unlock()
Definition: thread.h:57
return result
Definition: facAbsBiFact.cc:75

◆ receive()

string LibThread::SingularChannel::receive ( )
inline

Definition at line 411 of file shared.cc.

411 {
412 lock.lock();
413 while (q.empty()) {
414 cond.wait();
415 }
416 string result = q.front();
417 q.pop();
418 if (!q.empty())
419 cond.signal();
420 lock.unlock();
421 return result;
422 }
void wait()
Definition: thread.h:88
void signal()
Definition: thread.h:97

◆ send()

void LibThread::SingularChannel::send ( string  item)
inline

Definition at line 405 of file shared.cc.

405 {
406 lock.lock();
407 q.push(item);
408 cond.signal();
409 lock.unlock();
410 }

Field Documentation

◆ cond

ConditionVariable LibThread::SingularChannel::cond
private

Definition at line 401 of file shared.cc.

◆ lock

Lock LibThread::SingularChannel::lock
private

Definition at line 400 of file shared.cc.

◆ q

queue<string> LibThread::SingularChannel::q
private

Definition at line 399 of file shared.cc.


The documentation for this class was generated from the following file: