Loading...
Searching...
No Matches
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 392 of file shared.cc.

## Constructor & Destructor Documentation

## SingularChannel()

LibThread::SingularChannel::SingularChannel | ( |  | ) |

inline

Definition at line 398 of file shared.cc.

: SharedObject(), lock(), cond(&lock) { }
LibThread::SharedObject::SharedObject
SharedObject()
Definition shared.cc:156
LibThread::SingularChannel::cond
ConditionVariable cond
Definition shared.cc:396
LibThread::SingularChannel::lock
Lock lock
Definition shared.cc:395

## ~SingularChannel()

virtual LibThread::SingularChannel::~SingularChannel | ( |  | ) |

inline virtual

Definition at line 399 of file shared.cc.

{ }

## Member Function Documentation

## count()

long LibThread::SingularChannel::count | ( |  | ) |

inline

Definition at line 418 of file shared.cc.

{
lock.lock();
long result = q.size();
lock.unlock();
return result;
}
LibThread::SingularChannel::q
queue< string > q
Definition shared.cc:394
result
return result
Definition facAbsBiFact.cc:76

## receive()

string LibThread::SingularChannel::receive | ( |  | ) |

inline

Definition at line 406 of file shared.cc.

{
lock.lock();
while (q.empty()) {
cond.wait();
}
string result = q.front();
q.pop();
if (!q.empty())
cond.signal();
lock.unlock();
return result;
}

## send()

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

inline

Definition at line 400 of file shared.cc.

{
lock.lock();
q.push(item);
cond.signal();
lock.unlock();
}

## Field Documentation

## cond

ConditionVariable LibThread::SingularChannel::cond

private

Definition at line 396 of file shared.cc.

## lock

Lock LibThread::SingularChannel::lock

private

Definition at line 395 of file shared.cc.

## q

queue<string> LibThread::SingularChannel::q

private

Definition at line 394 of file shared.cc.

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

- Singular/dyn_modules/systhreads/shared.cc