Loading...
Searching...
No Matches
LibThread Namespace Reference

## Data Structures

class | ByteBuf
class | Channel
class | Command
class | SharedObject
class | Region
class | Transactional
class | TxTable
class | TxList
class | SingularChannel
class | SingularSyncVar
class | ThreadState
class | InterpreterThread
class | Job
struct | JobCompare
class | Trigger
struct | SchedInfo
class | ThreadPool
class | Scheduler
class | AccTrigger
class | CountTrigger
class | SetTrigger
class | ProcTrigger
class | EvalJob
class | ExecJob
class | ProcJob
class | KernelJob
class | RawKernelJob
class | SyncVar

## Typedefs

typedef std::map< std::string, SharedObject * > | SharedObjectTable
typedef SharedObject * | SharedObjectPtr
typedef SharedObjectPtr(* | SharedConstructor) ()
typedef queue< Job * > | JobQueue
typedef void *(* | ThreadFunc) (ThreadState *, void *)

## Functions

char * | allocate_space (size_t n)
void | free_space (size_t n, char *p)
ThreadPool * | createThreadPool (int threads, int prioThreads=0)
void | closeThreadPool (ThreadPool *pool, bool wait)
ThreadPool * | getCurrentThreadPool ()
Job * | createJob (void(*func)(leftv result, leftv arg))
Job * | createJob (void(*func)(long ndeps, Job **deps))
Job * | getCurrentJob ()
bool | getJobCancelled ()
bool | getJobCancelled (Job *job)
void | addJobArgs (Job *job, leftv arg)
void | setJobData (Job *job, void *data)
void * | getJobData (Job *job)
leftv | getJobResult (Job *job)
const char * | getJobName ()
void | setJobName (const char *)
Job * | startJob (ThreadPool *pool, Job *job, leftv arg)
Job * | startJob (ThreadPool *pool, Job *job)
void | cancelJob (Job *job)
void | waitJob (Job *job)
void | release (Job *job)
void | release (ThreadPool *pool)
void | retain (Job *job)
void | retain (ThreadPool *pool)
void | acquireShared (SharedObject *obj)
void | releaseShared (SharedObject *obj)
SharedObject * | makeSharedObject (SharedObjectTable &table, Lock *lock, int type, string &name, SharedConstructor scons)
SharedObject * | findSharedObject (SharedObjectTable &table, Lock *lock, string &name)
void * | shared_init (blackbox *b)
void * | new_shared (SharedObject *obj)
void | shared_destroy (blackbox *b, void *d)
void | rlock_destroy (blackbox *b, void *d)
void * | shared_copy (blackbox *b, void *d)
BOOLEAN | shared_assign (leftv l, leftv r)
BOOLEAN | rlock_assign (leftv l, leftv r)
BOOLEAN | shared_check_assign (blackbox *b, leftv l, leftv r)
BOOLEAN | shared_op2 (int op, leftv res, leftv a1, leftv a2)
BOOLEAN | shared_op3 (int op, leftv res, leftv a1, leftv a2, leftv a3)
char * | shared_string (blackbox *b, void *d)
char * | rlock_string (blackbox *b, void *d)
void | report (const char *fmt, const char *name)
int | wrong_num_args (const char *name, leftv arg, int n)
int | not_a_uri (const char *name, leftv arg)
int | not_a_region (const char *name, leftv arg)
char * | str (leftv arg)
SharedObject * | consTable ()
SharedObject * | consList ()
SharedObject * | consChannel ()
SharedObject * | consSyncVar ()
SharedObject * | consRegion ()
static void | appendArg (vector< leftv > &argv, string &s)
static void | appendArg (vector< leftv > &argv, leftv arg)
static void | appendArgCopy (vector< leftv > &argv, leftv arg)
static BOOLEAN | executeProc (sleftv &result, const char *procname, const vector< leftv > &argv)
BOOLEAN | makeAtomicTable (leftv result, leftv arg)
BOOLEAN | makeAtomicList (leftv result, leftv arg)
BOOLEAN | makeSharedTable (leftv result, leftv arg)
BOOLEAN | makeSharedList (leftv result, leftv arg)
BOOLEAN | makeChannel (leftv result, leftv arg)
BOOLEAN | makeSyncVar (leftv result, leftv arg)
BOOLEAN | makeRegion (leftv result, leftv arg)
BOOLEAN | findSharedObject (leftv result, leftv arg)
BOOLEAN | typeSharedObject (leftv result, leftv arg)
BOOLEAN | bindSharedObject (leftv result, leftv arg)
BOOLEAN | getTable (leftv result, leftv arg)
BOOLEAN | inTable (leftv result, leftv arg)
BOOLEAN | putTable (leftv result, leftv arg)
BOOLEAN | getList (leftv result, leftv arg)
BOOLEAN | putList (leftv result, leftv arg)
BOOLEAN | lockRegion (leftv result, leftv arg)
BOOLEAN | regionLock (leftv result, leftv arg)
BOOLEAN | unlockRegion (leftv result, leftv arg)
BOOLEAN | sendChannel (leftv result, leftv arg)
BOOLEAN | receiveChannel (leftv result, leftv arg)
BOOLEAN | statChannel (leftv result, leftv arg)
BOOLEAN | writeSyncVar (leftv result, leftv arg)
BOOLEAN | updateSyncVar (leftv result, leftv arg)
BOOLEAN | readSyncVar (leftv result, leftv arg)
BOOLEAN | statSyncVar (leftv result, leftv arg)
void | encode_shared (LinTree::LinTree &lintree, leftv val)
leftv | decode_shared (LinTree::LinTree &lintree)
void | ref_shared (LinTree::LinTree &lintree, int by)
void | installShared (int type)
void | makeSharedType (int &type, const char *name)
void | makeRegionlockType (int &type, const char *name)
void | setOption (int ch)
void | thread_init ()
void * | thread_main (void *arg)
void * | interpreter_thread (ThreadState *ts, void *arg)
static ThreadState * | newThread (void *(*thread_func)(ThreadState *, void *), void *arg, const char **error)
ThreadState * | createThread (void *(*thread_func)(ThreadState *, void *), void *arg)
void * | joinThread (ThreadState *ts)
static InterpreterThread * | createInterpreterThread (const char **error)
static BOOLEAN | createThread (leftv result, leftv arg)
static bool | joinInterpreterThread (InterpreterThread *thread)
static BOOLEAN | joinThread (leftv result, leftv arg)
static BOOLEAN | createThreadPool (leftv result, leftv arg)
static BOOLEAN | createThreadPoolSet (leftv result, leftv arg)
static BOOLEAN | getThreadPoolWorkers (leftv result, leftv arg)
static BOOLEAN | setThreadPoolWorkers (leftv result, leftv arg)
static BOOLEAN | getThreadPoolConcurrency (leftv result, leftv arg)
static BOOLEAN | setThreadPoolConcurrency (leftv result, leftv arg)
static BOOLEAN | closeThreadPool (leftv result, leftv arg)
BOOLEAN | currentThreadPool (leftv result, leftv arg)
BOOLEAN | setCurrentThreadPool (leftv result, leftv arg)
static BOOLEAN | createJob (leftv result, leftv arg)
static BOOLEAN | startJob (leftv result, leftv arg)
static BOOLEAN | waitJob (leftv result, leftv arg)
static BOOLEAN | cancelJob (leftv result, leftv arg)
static BOOLEAN | jobCancelled (leftv result, leftv arg)
const char * | getJobName (Job *job)
void | setJobName (Job *job, const char *name)
static BOOLEAN | createTrigger (leftv result, leftv arg)
static BOOLEAN | updateTrigger (leftv result, leftv arg)
static BOOLEAN | chainTrigger (leftv result, leftv arg)
static BOOLEAN | testTrigger (leftv result, leftv arg)
static BOOLEAN | scheduleJob (leftv result, leftv arg)
BOOLEAN | currentJob (leftv result, leftv arg)
BOOLEAN | threadID (leftv result, leftv arg)
BOOLEAN | mainThread (leftv result, leftv arg)
BOOLEAN | threadEval (leftv result, leftv arg)
BOOLEAN | threadExec (leftv result, leftv arg)
BOOLEAN | threadPoolExec (leftv result, leftv arg)
BOOLEAN | threadResult (leftv result, leftv arg)
BOOLEAN | setSharedName (leftv result, leftv arg)
BOOLEAN | getSharedName (leftv result, leftv arg)
ThreadState * | createThread (ThreadFunc body, void **arg, const char **error)
template<typename T>
T * | shared_alloc (std::size_t n)
template<typename T>
T * | shared_alloc0 (std::size_t n)
template<typename T>
T | shared_free (T *p)
template<typename T>
T * | shared_alloc (size_t n)
template<typename T>
T * | shared_alloc0 (size_t n)
template<typename T>
void | shared_free (T *p)

## Variables

const int | have_threads = 0
Lock | global_objects_lock
SharedObjectTable | global_objects
Lock | master_lock (true)
Lock | name_lock (true)
VAR long | thread_id
long | thread_counter
int | type_region
int | type_regionlock
int | type_channel
int | type_syncvar
int | type_atomic_table
int | type_shared_table
int | type_atomic_list
int | type_shared_list
int | type_thread
int | type_threadpool
int | type_job
int | type_trigger
Lock | thread_lock
ThreadState * | thread_state
STATIC_VAR ThreadPool * | currentThreadPoolRef
STATIC_VAR Job * | currentJobRef

## Data Structure Documentation

## LibThread::SchedInfo

struct LibThread::SchedInfo

Definition at line 1619 of file shared.cc.

Data Fields
Job * | job |
int | num |
Scheduler * | scheduler |

## Typedef Documentation

## JobQueue

typedef queue<Job *> LibThread::JobQueue

Definition at line 1615 of file shared.cc.

## SharedConstructor

typedef SharedObjectPtr(* LibThread::SharedConstructor) ()

Definition at line 242 of file shared.cc.

## SharedObjectPtr

typedef SharedObject* LibThread::SharedObjectPtr

Definition at line 241 of file shared.cc.

## SharedObjectTable

typedef std::map<std::string, SharedObject *> LibThread::SharedObjectTable

Definition at line 198 of file shared.cc.

## ThreadFunc

typedef void *(* LibThread::ThreadFunc) (ThreadState *, void *)

Definition at line 12 of file singthreads.h.

## Function Documentation

## acquireShared()

void LibThread::acquireShared | ( | SharedObject * | obj | ) |

Definition at line 188 of file shared.cc.

{
obj->incref();
}
LibThread::SharedObject::incref
void incref(int by=1)
Definition shared.cc:165

## addJobArgs()

void LibThread::addJobArgs | ( | Job * | job,
|  | leftv | arg )

Definition at line 2660 of file shared.cc.

{
ThreadPool *pool = job->pool;
if (pool) pool->scheduler->lock.lock();
while (arg) {
job->args.push_back(LinTree::to_string(arg));
arg = arg->next;
}
if (pool) pool->scheduler->lock.unlock();
}
LibThread::Job::args
vector< string > args
Definition shared.cc:1553
LibThread::Job::pool
ThreadPool * pool
Definition shared.cc:1546
LibThread::Scheduler::lock
Lock lock
Definition shared.cc:1667
LibThread::ThreadPool
Definition shared.cc:1628
LibThread::ThreadPool::scheduler
Scheduler * scheduler
Definition shared.cc:1630
Lock::lock
void lock()
Definition thread.h:46
Lock::unlock
void unlock()
Definition thread.h:57
sleftv::next
leftv next
Definition subexpr.h:86
LinTree::to_string
std::string to_string(leftv val)
Definition lintree.cc:843

## allocate_space()

char * LibThread::allocate_space | ( | size_t | n | ) |

## appendArg() [1/2]

void LibThread::appendArg | ( | vector< leftv > & | argv,
|  | leftv | arg )

static

Definition at line 733 of file shared.cc.

{
argv.push_back(arg);
}

## appendArg() [2/2]

void LibThread::appendArg | ( | vector< leftv > & | argv,
|  | string & | s )

static

Definition at line 723 of file shared.cc.

{
if (s.size() == 0) return;
leftv val = LinTree::from_string(s);
if (val->Typ() == NONE) {
omFreeBin(val, sleftv_bin);
return;
}
argv.push_back(val);
}
sleftv::Typ
int Typ()
Definition subexpr.cc:1048
s
const CanonicalForm int s
Definition facAbsFact.cc:51
sleftv_bin
EXTERN_VAR omBin sleftv_bin
Definition ipid.h:145
LinTree::from_string
leftv from_string(std::string &str)
Definition lintree.cc:854
omFreeBin
#define omFreeBin(addr, bin)
Definition omAllocDecl.h:259
leftv
sleftv * leftv
Definition structs.h:53
NONE
#define NONE
Definition tok.h:223

## appendArgCopy()

void LibThread::appendArgCopy | ( | vector< leftv > & | argv,
|  | leftv | arg )

static

Definition at line 737 of file shared.cc.

{
leftv val = (leftv) omAlloc0Bin(sleftv_bin);
val->Copy(arg);
argv.push_back(val);
}
sleftv::Copy
void Copy(leftv e)
Definition subexpr.cc:689
omAlloc0Bin
#define omAlloc0Bin(bin)
Definition omAllocDecl.h:206

## bindSharedObject()

BOOLEAN LibThread::bindSharedObject | ( | leftv | result,
|  | leftv | arg )

Definition at line 919 of file shared.cc.

{
if (wrong_num_args("bindSharedObject", arg, 1))
return TRUE;
if (not_a_uri("bindSharedObject", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = findSharedObject(global_objects,
&global_objects_lock, uri);
if (!obj) {
WerrorS("bindSharedObject: cannot find object");
return TRUE;
}
result->rtyp = obj->get_type();
result->data = new_shared(obj);
return FALSE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
LibThread::SharedObject
Definition shared.cc:149
LibThread::SharedObject::get_type
int get_type()
Definition shared.cc:159
result
return result
Definition facAbsBiFact.cc:76
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
LibThread::str
char * str(leftv arg)
Definition shared.cc:699
LibThread::not_a_uri
int not_a_uri(const char *name, leftv arg)
Definition shared.cc:682
LibThread::new_shared
void * new_shared(SharedObject *obj)
Definition shared.cc:486
LibThread::global_objects_lock
Lock global_objects_lock
Definition shared.cc:221
LibThread::wrong_num_args
int wrong_num_args(const char *name, leftv arg, int n)
Definition shared.cc:667
LibThread::global_objects
SharedObjectTable global_objects
Definition shared.cc:222
LibThread::findSharedObject
SharedObject * findSharedObject(SharedObjectTable &table, Lock *lock, string &name)
Definition shared.cc:266

## cancelJob() [1/2]

void LibThread::cancelJob | ( | Job * | job | ) |

Definition at line 2509 of file shared.cc.

{
ThreadPool *pool = job->pool;
if (pool) pool->cancelJob(job);
}
LibThread::ThreadPool::cancelJob
void cancelJob(Job *job)
Definition shared.cc:1943

## cancelJob() [2/2]

BOOLEAN LibThread::cancelJob | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2590 of file shared.cc.

{
Command cmd("cancelJob", result, arg);
cmd.check_argc(1);
cmd.check_arg(0, type_job, "argument must be a job");
cmd.check_init(0, "job not initialized");
if (cmd.ok()) {
Job *job = cmd.shared_arg<Job>(0);
ThreadPool *pool = job->pool;
if (!pool) {
return cmd.abort("job has not yet been started or scheduled");
}
pool->cancelJob(job);
cmd.no_result();
}
return cmd.status();
}
LibThread::Command
Definition shared.cc:36
LibThread::Job
Definition shared.cc:1544
LibThread::type_job
int type_job
Definition shared.cc:238

## chainTrigger()

BOOLEAN LibThread::chainTrigger | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2752 of file shared.cc.

{
Command cmd("chainTrigger", result, arg);
cmd.check_argc(2);
cmd.check_arg(0, type_trigger, "first argument must be a trigger");
cmd.check_arg(1, type_trigger, type_job,
"second argument must be a trigger or job");
cmd.check_init(0, "trigger not initialized");
cmd.check_init(1, "trigger/job not initialized");
if (cmd.ok()) {
Trigger *trigger = cmd.shared_arg<Trigger>(0);
Job *job = cmd.shared_arg<Job>(1);
if (trigger->pool != job->pool)
return cmd.abort("arguments use different threadpools");
ThreadPool *pool = trigger->pool;
pool->scheduler->lock.lock();
job->triggers.push_back(trigger);
pool->scheduler->lock.unlock();
}
return cmd.status();
}
LibThread::Trigger
Definition shared.cc:1593
LibThread::type_trigger
int type_trigger
Definition shared.cc:239

## closeThreadPool() [1/2]

BOOLEAN LibThread::closeThreadPool | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2308 of file shared.cc.

{
Command cmd("closeThreadPool", result, arg);
cmd.check_argc(1, 2);
cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
cmd.check_init(0, "threadpool not initialized");
if (cmd.nargs() > 1)
cmd.check_arg(1, INT_CMD, "optional argument must be an integer");
if (cmd.ok()) {
ThreadPool *pool = *(ThreadPool **)(cmd.arg(0));
bool wait = cmd.nargs() == 2 ? (cmd.int_arg(1) != 0) : 1;
pool->shutdown(wait);
cmd.no_result();
}
return cmd.status();
}
LibThread::ThreadPool::shutdown
void shutdown(bool wait)
Definition shared.cc:1924
LibThread::type_threadpool
int type_threadpool
Definition shared.cc:237
wait
wait
Definition si_signals.h:61
INT_CMD
@ INT_CMD
Definition tok.h:96

## closeThreadPool() [2/2]

void LibThread::closeThreadPool | ( | ThreadPool * | pool,
|  | bool | wait )

Definition at line 2324 of file shared.cc.

{
pool->shutdown(wait);
}

## consChannel()

SharedObject * LibThread::consChannel | ( |  | ) |

Definition at line 711 of file shared.cc.

{
return new SingularChannel();
}
LibThread::SingularChannel
Definition shared.cc:392

## consList()

SharedObject * LibThread::consList | ( |  | ) |

Definition at line 707 of file shared.cc.

{
return new TxList();
}
LibThread::TxList
Definition shared.cc:352

## consRegion()

SharedObject * LibThread::consRegion | ( |  | ) |

Definition at line 719 of file shared.cc.

{
return new Region();
}
LibThread::Region
Definition shared.cc:200

## consSyncVar()

SharedObject * LibThread::consSyncVar | ( |  | ) |

Definition at line 715 of file shared.cc.

{
return new SingularSyncVar();
}
LibThread::SingularSyncVar
Definition shared.cc:426

## consTable()

SharedObject * LibThread::consTable | ( |  | ) |

Definition at line 703 of file shared.cc.

{
return new TxTable();
}
LibThread::TxTable
Definition shared.cc:315

## createInterpreterThread()

InterpreterThread * LibThread::createInterpreterThread | ( | const char ** | error | ) |

static

Definition at line 1480 of file shared.cc.

{
ThreadState *ts = newThread(interpreter_thread, NULL, error);
if (*error) return NULL;
InterpreterThread *thread = new InterpreterThread(ts);
char buf[10];
snprintf(buf,10, "%d", ts->index);
string name(buf);
thread->set_name(name);
thread->set_type(type_thread);
return thread;
}
LibThread::InterpreterThread
Definition shared.cc:1419
LibThread::ThreadState
Definition shared.cc:1331
LibThread::ThreadState::index
int index
Definition shared.cc:1335
name
char name(const Variable &v)
Definition factory.h:189
error
#define error(a)
Definition mpr_numeric.cc:966
LibThread::type_thread
int type_thread
Definition shared.cc:236
LibThread::newThread
static ThreadState * newThread(void *(*thread_func)(ThreadState *, void *), void *arg, const char **error)
Definition shared.cc:1431
LibThread::interpreter_thread
void * interpreter_thread(ThreadState *ts, void *arg)
Definition shared.cc:1386
NULL
#define NULL
Definition omList.c:12
buf
int status int void * buf
Definition si_signals.h:69

## createJob() [1/3]

BOOLEAN LibThread::createJob | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2444 of file shared.cc.

{
Command cmd("createJob", result, arg);
cmd.check_argc_min(1);
cmd.check_arg(0, STRING_CMD, COMMAND,
"job name must be a string or quote expression");
if (cmd.ok()) {
if (cmd.test_arg(0, STRING_CMD)) {
ProcJob *job = new ProcJob((char *)(cmd.arg(0)));
for (leftv a = arg->next; a != NULL; a = a->next) {
job->args.push_back(LinTree::to_string(a));
}
cmd.set_result(type_job, new_shared(job));
} else {
cmd.check_argc(1);
Job *job = new EvalJob();
job->args.push_back(LinTree::to_string(arg));
cmd.set_result(type_job, new_shared(job));
}
}
return cmd.status();
}
LibThread::EvalJob
Definition shared.cc:2355
LibThread::ProcJob
Definition shared.cc:2376
STRING_CMD
@ STRING_CMD
Definition tok.h:187
COMMAND
#define COMMAND
Definition tok.h:29

## createJob() [2/3]

Job * LibThread::createJob | ( | void(* | func )(leftv result, leftv arg) | ) |

Definition at line 2466 of file shared.cc.

{
KernelJob *job = new KernelJob(func);
return job;
}
LibThread::KernelJob
Definition shared.cc:2400

## createJob() [3/3]

Job * LibThread::createJob | ( | void(* | func )(long ndeps, Job **deps) | ) |

Definition at line 2471 of file shared.cc.

{
RawKernelJob *job = new RawKernelJob(func);
return job;
}
LibThread::RawKernelJob
Definition shared.cc:2429

## createThread() [1/3]

BOOLEAN LibThread::createThread | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 1492 of file shared.cc.

{
Command cmd("createThread", result, arg);
cmd.check_argc(0);
const char *error;
if (!have_threads)
cmd.report("thread support not available");
if (!cmd.ok()) return cmd.status();
InterpreterThread *thread = createInterpreterThread(&error);
if (error) {
return cmd.abort(error);
}
cmd.set_result(type_thread, new_shared(thread));
return cmd.status();
}
LibThread::createInterpreterThread
static InterpreterThread * createInterpreterThread(const char **error)
Definition shared.cc:1480
LibThread::have_threads
const int have_threads
Definition shared.cc:33

## createThread() [2/3]

ThreadState * LibThread::createThread | ( | ThreadFunc | body,
|  | void ** | arg,
|  | const char ** | error )

## createThread() [3/3]

ThreadState * LibThread::createThread | ( | void *(* | thread_func )(ThreadState *, void *),
|  | void * | arg )

Definition at line 1464 of file shared.cc.

{
return newThread(thread_func, arg, NULL);
}

## createThreadPool() [1/2]

ThreadPool * LibThread::createThreadPool | ( | int | threads,
|  | int | prioThreads = 0 )

Definition at line 2213 of file shared.cc.

{
ThreadPool *pool = new ThreadPool((int) nthreads);
pool->set_type(type_threadpool);
for (int i = 0; i <nthreads; i++) {
const char *error;
SchedInfo *info = new SchedInfo();
info->scheduler = pool->scheduler;
acquireShared(pool);
info->job = NULL;
info->num = i;
ThreadState *thread = newThread(Scheduler::main, info, &error);
if (!thread) {
return NULL;
}
pool->addThread(thread);
}
return pool;
}
i
int i
Definition cfEzgcd.cc:132
LibThread::Scheduler::main
static void * main(ThreadState *ts, void *arg)
Definition shared.cc:1851
LibThread::SharedObject::set_type
void set_type(int type_init)
Definition shared.cc:158
LibThread::ThreadPool::addThread
void addThread(ThreadState *thread)
Definition shared.cc:1925
info
#define info
Definition libparse.cc:1256
LibThread::acquireShared
void acquireShared(SharedObject *obj)
Definition shared.cc:188
LibThread::SchedInfo
Definition shared.cc:1619

## createThreadPool() [2/2]

BOOLEAN LibThread::createThreadPool | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2127 of file shared.cc.

{
long n;
Command cmd("createThreadPool", result, arg);
cmd.check_argc(1, 2);
cmd.check_arg(0, INT_CMD, "first argument must be an integer");
if (cmd.ok()) {
n = (long) cmd.arg(0);
if (n < 0) cmd.report("number of threads must be non-negative");
else if (n >= 256) cmd.report("number of threads too large");
if (!have_threads && n != 0)
cmd.report("in single-threaded mode, number of threads must be zero");
}
if (cmd.ok()) {
ThreadPool *pool = new ThreadPool((int) n);
pool->set_type(type_threadpool);
for (int i = 0; i <n; i++) {
const char *error;
SchedInfo *info = new SchedInfo();
info->scheduler = pool->scheduler;
acquireShared(pool->scheduler);
info->job = NULL;
info->num = i;
ThreadState *thread = newThread(Scheduler::main, info, &error);
if (!thread) {
// TODO: clean up bad pool
return cmd.abort(error);
}
pool->addThread(thread);
}
cmd.set_result(type_threadpool, new_shared(pool));
}
return cmd.status();
}

## createThreadPoolSet()

BOOLEAN LibThread::createThreadPoolSet | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2161 of file shared.cc.

{
Command cmd("createThreadPoolSet", result, arg);
cmd.check_argc(2);
cmd.check_arg(0, INT_CMD, "first argument must be an integer");
cmd.check_arg(1, LIST_CMD, "second argument must be a list of integers");
lists l;
int n;
if (cmd.ok()) {
l = (lists) (cmd.arg(1));
n = lSize(l)+1;
if (n == 0)
return cmd.abort("second argument must not be empty");
for (int i = 0; i < n; i++) {
if (l->m[i].Typ() != INT_CMD)
return cmd.abort("second argument must be a list of integers");
}
}
lists pools = (lists) omAlloc0Bin(slists_bin);
pools->Init(n);
if (cmd.ok()) {
long s = 0;
for (int i = 0; i < n; i++) {
s += (long) (l->m[i].Data());
}
Scheduler *sched = new Scheduler((int)s);
sched->set_maxconcurrency(cmd.int_arg(0));
for (int i = 0; i < n; i++) {
long m = (long) (l->m[i].Data());
ThreadPool *pool = new ThreadPool(sched, (int) m);
pool->set_type(type_threadpool);
for (int j = 0; j < m; j++) {
const char *error;
SchedInfo *info = new SchedInfo();
info->scheduler = pool->scheduler;
acquireShared(pool->scheduler);
info->job = NULL;
info->num = i;
ThreadState *thread = newThread(Scheduler::main, info, &error);
if (!thread) {
// TODO: clean up bad pool
return cmd.abort(error);
}
pool->addThread(thread);
}
pools->m[i].rtyp = type_threadpool;
pools->m[i].data = new_shared(pool);
}
cmd.set_result(LIST_CMD, pools);
}
return cmd.status();
}
l
int l
Definition cfEzgcd.cc:100
m
int m
Definition cfEzgcd.cc:128
LibThread::Scheduler
Definition shared.cc:1649
LibThread::Scheduler::set_maxconcurrency
void set_maxconcurrency(int n)
Definition shared.cc:1677
sleftv::rtyp
int rtyp
Definition subexpr.h:91
sleftv::data
void * data
Definition subexpr.h:88
slists::m
sleftv * m
Definition lists.h:46
slists::Init
INLINE_THIS void Init(int l=0)
j
int j
Definition facHensel.cc:110
slists_bin
VAR omBin slists_bin
Definition lists.cc:23
lSize
int lSize(lists L)
Definition lists.cc:25
lists
slists * lists
Definition mpr_numeric.h:146
LIST_CMD
@ LIST_CMD
Definition tok.h:118

## createTrigger()

BOOLEAN LibThread::createTrigger | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2687 of file shared.cc.

{
Command cmd("createTrigger", result, arg);
cmd.check_argc_min(1);
int has_pool = cmd.test_arg(0, type_threadpool);
ThreadPool *pool;
if (has_pool) {
cmd.check_init(0, "threadpool not initialized");
pool = cmd.shared_arg<ThreadPool>(0);
} else {
pool = currentThreadPoolRef;
if (!pool)
return cmd.abort("no default threadpool");
}
cmd.check_argc(has_pool + 2);
cmd.check_arg(has_pool + 0, STRING_CMD, "trigger subtype must be a string");
const char *kind = (const char *)(cmd.arg(has_pool + 0));
if (0 == strcmp(kind, "proc")) {
cmd.check_arg(has_pool + 1, STRING_CMD, "proc trigger argument must be a string");
} else {
cmd.check_arg(has_pool + 1, INT_CMD, "trigger argument must be an integer");
}
if (cmd.ok()) {
Trigger *trigger;
long n = (long) (cmd.arg(has_pool + 1));
if (n < 0)
return cmd.abort("trigger argument must be a non-negative integer");
if (0 == strcmp(kind, "acc")) {
trigger = new AccTrigger(n);
} else if (0 == strcmp(kind, "count")) {
trigger = new CountTrigger(n);
} else if (0 == strcmp(kind, "set")) {
trigger = new SetTrigger(n);
} else if (0 == strcmp(kind, "proc")) {
trigger = new ProcTrigger((const char *) cmd.arg(has_pool + 1));
} else {
return cmd.abort("unknown trigger subtype");
}
pool->attachJob(trigger);
cmd.set_result(type_trigger, new_shared(trigger));
}
return cmd.status();
}
LibThread::AccTrigger
Definition shared.cc:1990
LibThread::CountTrigger
Definition shared.cc:2029
LibThread::ProcTrigger
Definition shared.cc:2082
LibThread::SetTrigger
Definition shared.cc:2052
LibThread::ThreadPool::attachJob
void attachJob(Job *job)
Definition shared.cc:1928
LibThread::currentThreadPoolRef
STATIC_VAR ThreadPool * currentThreadPoolRef
Definition shared.cc:1625

## currentJob()

BOOLEAN LibThread::currentJob | ( | leftv | result,
|  | leftv | arg )

Definition at line 2893 of file shared.cc.

{
Command cmd("currentJob", result, arg);
cmd.check_argc(0);
Job *job = currentJobRef;
if (job) {
cmd.set_result(type_job, new_shared(job));
} else {
cmd.report("no current job");
}
return cmd.status();
}
LibThread::currentJobRef
STATIC_VAR Job * currentJobRef
Definition shared.cc:1626

## currentThreadPool()

BOOLEAN LibThread::currentThreadPool | ( | leftv | result,
|  | leftv | arg )

Definition at line 2329 of file shared.cc.

{
Command cmd("currentThreadPool", result, arg);
cmd.check_argc(0);
ThreadPool *pool = currentThreadPoolRef;
if (pool) {
cmd.set_result(type_threadpool, new_shared(pool));
} else {
cmd.report("no current threadpool");
}
return cmd.status();
}

## decode_shared()

leftv LibThread::decode_shared | ( | LinTree::LinTree & | lintree | ) |

Definition at line 1276 of file shared.cc.

{
int type = lintree.get_prev<int>();
SharedObject *obj = lintree.get<SharedObject *>();
leftv result = (leftv) omAlloc0Bin(sleftv_bin);
result->rtyp = type;
result->data = (void *)new_shared(obj);
return result;
}
LinTree::LinTree::get
T get()
Definition lintree.h:48
LinTree::LinTree::get_prev
T get_prev()
Definition lintree.h:55

## encode_shared()

void LibThread::encode_shared | ( | LinTree::LinTree & | lintree,
|  | leftv | val )

Definition at line 1270 of file shared.cc.

{
SharedObject *obj = *(SharedObject **)(val->Data());
acquireShared(obj);
lintree.put(obj);
}
LinTree::LinTree::put
void put(T data)
Definition lintree.h:61
sleftv::Data
void * Data()
Definition subexpr.cc:1192

## executeProc()

BOOLEAN LibThread::executeProc | ( | sleftv & | result,
|  | const char * | procname,
|  | const vector< leftv > & | argv )

static

Definition at line 744 of file shared.cc.

{
leftv procnode = (leftv) omAlloc0Bin(sleftv_bin);
procnode->name = omStrDup(procname);
procnode->req_packhdl = basePack;
int error = procnode->Eval();
if (error) {
Werror("procedure \"%s\" not found", procname);
omFreeBin(procnode, sleftv_bin);
return TRUE;
}
memset(&result, 0, sizeof(result));
leftv *tail = &procnode->next;
for (unsigned i = 0; i < argv.size(); i++) {
*tail = argv[i];
tail = &(*tail)->next;
}
*tail = NULL;
error = iiExprArithM(&result, procnode, '(');
procnode->CleanUp();
omFreeBin(procnode, sleftv_bin);
if (error) {
Werror("procedure call of \"%s\" failed", procname);
return TRUE;
}
return FALSE;
}
sleftv::name
const char * name
Definition subexpr.h:87
sleftv::req_packhdl
package req_packhdl
Definition subexpr.h:106
sleftv::Eval
int Eval()
Definition subexpr.cc:2000
sleftv::CleanUp
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
iiExprArithM
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9666
basePack
VAR package basePack
Definition ipid.cc:56
omStrDup
#define omStrDup(s)
Definition omAllocDecl.h:263
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## findSharedObject() [1/2]

BOOLEAN LibThread::findSharedObject | ( | leftv | result,
|  | leftv | arg )

Definition at line 875 of file shared.cc.

{
if (wrong_num_args("findSharedObject", arg, 1))
return TRUE;
if (not_a_uri("findSharedObject", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = findSharedObject(global_objects,
&global_objects_lock, uri);
result->rtyp = INT_CMD;
result->data = (char *)(long)(obj != NULL);
return FALSE;
}

## findSharedObject() [2/2]

SharedObject * LibThread::findSharedObject | ( | SharedObjectTable & | table,
|  | Lock * | lock,
|  | string & | name )

Definition at line 266 of file shared.cc.

{
int was_locked = lock->is_locked();
SharedObject *result = NULL;
if (!was_locked)
lock->lock();
if (table.count(name)) {
result = table[name];
}
if (!was_locked)
lock->unlock();
return result;
}
Lock::is_locked
bool is_locked()
Definition thread.h:68

## free_space()

void LibThread::free_space | ( | size_t | n,
|  | char * | p )

## getCurrentJob()

Job * LibThread::getCurrentJob | ( |  | ) |

Definition at line 2514 of file shared.cc.

{
return currentJobRef;
}

## getCurrentThreadPool()

ThreadPool * LibThread::getCurrentThreadPool | ( |  | ) |

Definition at line 2240 of file shared.cc.

{
return currentThreadPoolRef;
}

## getJobCancelled() [1/2]

bool LibThread::getJobCancelled | ( |  | ) |

Definition at line 2640 of file shared.cc.

{
return getJobCancelled(currentJobRef);
}
LibThread::getJobCancelled
bool getJobCancelled()
Definition shared.cc:2640

## getJobCancelled() [2/2]

bool LibThread::getJobCancelled | ( | Job * | job | ) |

Definition at line 2632 of file shared.cc.

{
ThreadPool *pool = job->pool;
if (pool) pool->scheduler->lock.lock();
bool result = job->cancelled;
if (pool) pool->scheduler->lock.unlock();
return result;
}
LibThread::Job::cancelled
bool cancelled
Definition shared.cc:1560

## getJobData()

void * LibThread::getJobData | ( | Job * | job | ) |

Definition at line 2652 of file shared.cc.

{
ThreadPool *pool = job->pool;
if (pool) pool->scheduler->lock.lock();
void *result = job->data;
if (pool) pool->scheduler->lock.unlock();
return result;
}
LibThread::Job::data
void * data
Definition shared.cc:1555

## getJobName() [1/2]

const char * LibThread::getJobName | ( |  | ) |

## getJobName() [2/2]

const char * LibThread::getJobName | ( | Job * | job | ) |

Definition at line 2678 of file shared.cc.

{
// TODO
return "";
}

## getJobResult()

leftv LibThread::getJobResult | ( | Job * | job | ) |

Definition at line 2670 of file shared.cc.

{
ThreadPool *pool = job->pool;
if (pool) pool->scheduler->lock.lock();
leftv result = LinTree::from_string(job->result);
if (pool) pool->scheduler->lock.unlock();
return result;
}
LibThread::Job::result
string result
Definition shared.cc:1554

## getList()

BOOLEAN LibThread::getList | ( | leftv | result,
|  | leftv | arg )

Definition at line 1023 of file shared.cc.

{
if (wrong_num_args("getList", arg, 2))
return TRUE;
if (arg->Typ() != type_atomic_list && arg->Typ() != type_shared_list) {
WerrorS("getList: not a valid list (atomic or shared)");
return TRUE;
}
if (arg->next->Typ() != INT_CMD) {
WerrorS("getList: index must be an integer");
return TRUE;
}
TxList *list = *(TxList **) arg->Data();
if (!list) {
WerrorS("getList: list has not been initialized");
return TRUE;
}
long index = (long)(arg->next->Data());
string value;
int success = list->get(index, value);
if (success < 0) {
WerrorS("getList: region not acquired");
return TRUE;
}
if (success == 0) {
WerrorS("getList: no value at position");
return TRUE;
}
leftv tmp = LinTree::from_string(value);
result->rtyp = tmp->Typ();
result->data = tmp->Data();
return FALSE;
}
LibThread::type_atomic_list
int type_atomic_list
Definition shared.cc:234
LibThread::type_shared_list
int type_shared_list
Definition shared.cc:235
index
static int index(p_Length length, p_Ord ord)
Definition p_Procs_Impl.h:592

## getSharedName()

BOOLEAN LibThread::getSharedName | ( | leftv | result,
|  | leftv | arg )

Definition at line 3051 of file shared.cc.

{
Command cmd("getSharedName", result, arg);
cmd.check_argc(1);
int type = cmd.argtype(0);
cmd.check_init(0, "first argument is not initialized");
if (type != type_job && type != type_trigger && type != type_threadpool) {
cmd.report("first argument must be a job, trigger, or threadpool");
}
if (cmd.ok()) {
SharedObject *obj = cmd.shared_arg<SharedObject>(0);
name_lock.lock();
cmd.set_result(obj->get_name().c_str());
name_lock.unlock();
}
return cmd.status();
}
LibThread::SharedObject::get_name
std::string & get_name()
Definition shared.cc:164
LibThread::name_lock
Lock name_lock(true)

## getTable()

BOOLEAN LibThread::getTable | ( | leftv | result,
|  | leftv | arg )

Definition at line 936 of file shared.cc.

{
if (wrong_num_args("getTable", arg, 2))
return TRUE;
if (arg->Typ() != type_atomic_table && arg->Typ() != type_shared_table) {
WerrorS("getTable: not a valid table");
return TRUE;
}
if (arg->next->Typ() != STRING_CMD) {
WerrorS("getTable: not a valid table key");
return TRUE;
}
TxTable *table = *(TxTable **) arg->Data();
if (!table) {
WerrorS("getTable: table has not been initialized");
return TRUE;
}
string key = (char *)(arg->next->Data());
string value;
int success = table->get(key, value);
if (success < 0) {
WerrorS("getTable: region not acquired");
return TRUE;
}
if (success == 0) {
WerrorS("getTable: key not found");
return TRUE;
}
leftv tmp = LinTree::from_string(value);
result->rtyp = tmp->Typ();
result->data = tmp->Data();
return FALSE;
}
LibThread::TxTable::get
int get(string &key, string &value)
Definition shared.cc:333
LibThread::type_atomic_table
int type_atomic_table
Definition shared.cc:232
LibThread::type_shared_table
int type_shared_table
Definition shared.cc:233

## getThreadPoolConcurrency()

BOOLEAN LibThread::getThreadPoolConcurrency | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2276 of file shared.cc.

{
Command cmd("getThreadPoolConcurrency", result, arg);
cmd.check_argc(1);
cmd.check_arg(0, type_threadpool, "argument must be a threadpool");
cmd.check_init(0, "threadpool not initialized");
if (cmd.ok()) {
ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
Scheduler *sched = pool->scheduler;
sched->lock.lock();
cmd.set_result(INT_CMD, sched->get_maxconcurrency());
sched->lock.unlock();
}
return cmd.status();
}

## getThreadPoolWorkers()

BOOLEAN LibThread::getThreadPoolWorkers | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2244 of file shared.cc.

{
Command cmd("getThreadPoolWorkers", result, arg);
cmd.check_argc(1);
cmd.check_arg(0, type_threadpool, "argument must be a threadpool");
cmd.check_init(0, "threadpool not initialized");
int r = 0;
if (cmd.ok()) {
ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
Scheduler *sched = pool->scheduler;
sched->lock.lock();
r = sched->threadpool_size(pool);
sched->lock.unlock();
cmd.set_result(INT_CMD, r);
}
return cmd.status();
}

## installShared()

void LibThread::installShared | ( | int | type | ) |

Definition at line 1297 of file shared.cc.

{
LinTree::install(type, encode_shared, decode_shared, ref_shared);
}
LibThread::ref_shared
void ref_shared(LinTree::LinTree &lintree, int by)
Definition shared.cc:1285
LibThread::encode_shared
void encode_shared(LinTree::LinTree &lintree, leftv val)
Definition shared.cc:1270
LibThread::decode_shared
leftv decode_shared(LinTree::LinTree &lintree)
Definition shared.cc:1276
LinTree::install
void install(int typ, LinTreeEncodeFunc enc, LinTreeDecodeFunc dec, LinTreeRefFunc ref)
Definition lintree.cc:51

## inTable()

BOOLEAN LibThread::inTable | ( | leftv | result,
|  | leftv | arg )

Definition at line 969 of file shared.cc.

{
if (wrong_num_args("inTable", arg, 2))
return TRUE;
if (arg->Typ() != type_atomic_table && arg->Typ() != type_shared_table) {
WerrorS("inTable: not a valid table");
return TRUE;
}
if (arg->next->Typ() != STRING_CMD) {
WerrorS("inTable: not a valid table key");
return TRUE;
}
TxTable *table = *(TxTable **) arg->Data();
if (!table) {
WerrorS("inTable: table has not been initialized");
return TRUE;
}
string key = (char *)(arg->next->Data());
int success = table->check(key);
if (success < 0) {
WerrorS("inTable: region not acquired");
return TRUE;
}
result->rtyp = INT_CMD;
result->data = (char *)(long)(success);
return FALSE;
}
LibThread::TxTable::check
int check(string &key)
Definition shared.cc:343

## interpreter_thread()

void * LibThread::interpreter_thread | ( | ThreadState * | ts,
|  | void * | arg )

Definition at line 1386 of file shared.cc.

{
ts->lock.lock();
for (;;) {
bool eval = false;
while (ts->to_thread.empty())
ts->to_cond.wait();
/* TODO */
string expr = ts->to_thread.front();
switch (expr[0]) {
case '\0': case 'q':
ts->lock.unlock();
return NULL;
case 'x':
eval = false;
break;
case 'e':
eval = true;
break;
}
ts->to_thread.pop();
expr = ts->to_thread.front();
/* this will implicitly eval commands */
leftv val = LinTree::from_string(expr);
expr = LinTree::to_string(val);
ts->to_thread.pop();
if (eval)
ts->from_thread.push(expr);
ts->from_cond.signal();
}
ts->lock.unlock();
return NULL;
}
ConditionVariable::wait
void wait()
Definition thread.h:88
ConditionVariable::signal
void signal()
Definition thread.h:97
LibThread::ThreadState::lock
Lock lock
Definition shared.cc:1340
LibThread::ThreadState::to_cond
ConditionVariable to_cond
Definition shared.cc:1341
LibThread::ThreadState::from_thread
queue< string > from_thread
Definition shared.cc:1344
LibThread::ThreadState::from_cond
ConditionVariable from_cond
Definition shared.cc:1342
LibThread::ThreadState::to_thread
queue< string > to_thread
Definition shared.cc:1343
eval
CFList & eval
Definition facFactorize.cc:47

## jobCancelled()

BOOLEAN LibThread::jobCancelled | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2607 of file shared.cc.

{
Job *job;
Command cmd("jobCancelled", result, arg);
cmd.check_argc(0, 1);
if (cmd.nargs() == 1) {
cmd.check_arg(0, type_job, "argument must be a job");
cmd.check_init(0, "job not initialized");
job = cmd.shared_arg<Job>(0);
} else {
job = currentJobRef;
if (!job)
cmd.report("no current job");
}
if (cmd.ok()) {
ThreadPool *pool = job->pool;
if (!pool) {
return cmd.abort("job has not yet been started or scheduled");
}
pool->scheduler->lock.lock();
cmd.set_result((long) job->cancelled);
pool->scheduler->lock.unlock();
}
return cmd.status();
}

## joinInterpreterThread()

bool LibThread::joinInterpreterThread | ( | InterpreterThread * | thread | ) |

static

Definition at line 1507 of file shared.cc.

{
ThreadState *ts = thread->getThreadState();
if (ts && ts->parent != pthread_self()) {
return false;
}
ts->lock.lock();
string quit("q");
ts->to_thread.push(quit);
ts->to_cond.signal();
ts->lock.unlock();
pthread_join(ts->id, NULL);
thread_lock.lock();
ts->running = false;
ts->active = false;
thread->clearThreadState();
thread_lock.unlock();
return true;
}
LibThread::ThreadState::id
pthread_t id
Definition shared.cc:1338
LibThread::ThreadState::running
bool running
Definition shared.cc:1334
LibThread::ThreadState::parent
pthread_t parent
Definition shared.cc:1339
LibThread::ThreadState::active
bool active
Definition shared.cc:1333
LibThread::thread_lock
Lock thread_lock
Definition shared.cc:1359

## joinThread() [1/2]

BOOLEAN LibThread::joinThread | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 1526 of file shared.cc.

{
if (wrong_num_args("joinThread", arg, 1))
return TRUE;
if (arg->Typ() != type_thread) {
WerrorS("joinThread: argument is not a thread");
return TRUE;
}
InterpreterThread *thread = *(InterpreterThread **)arg->Data();
if (!joinInterpreterThread(thread)) {
WerrorS("joinThread: can only be called from parent thread");
return TRUE;
}
return FALSE;
}
LibThread::joinInterpreterThread
static bool joinInterpreterThread(InterpreterThread *thread)
Definition shared.cc:1507

## joinThread() [2/2]

void * LibThread::joinThread | ( | ThreadState * | ts | ) |

Definition at line 1469 of file shared.cc.

{
void *result;
pthread_join(ts->id, NULL);
result = ts->result;
thread_lock.lock();
ts->running = false;
ts->active = false;
thread_lock.unlock();
return result;
}
LibThread::ThreadState::result
void * result
Definition shared.cc:1337

## lockRegion()

BOOLEAN LibThread::lockRegion | ( | leftv | result,
|  | leftv | arg )

Definition at line 1083 of file shared.cc.

{
if (wrong_num_args("lockRegion", arg, 1))
return TRUE;
if (not_a_region("lockRegion", arg))
return TRUE;
Region *region = *(Region **)arg->Data();
if (region->is_locked()) {
WerrorS("lockRegion: region is already locked");
return TRUE;
}
region->lock();
result->rtyp = NONE;
return FALSE;
}
LibThread::Region::lock
void lock()
Definition shared.cc:208
LibThread::Region::is_locked
int is_locked()
Definition shared.cc:216
LibThread::not_a_region
int not_a_region(const char *name, leftv arg)
Definition shared.cc:690

## mainThread()

BOOLEAN LibThread::mainThread | ( | leftv | result,
|  | leftv | arg )

Definition at line 2914 of file shared.cc.

{
if (wrong_num_args("mainThread", arg, 0))
return TRUE;
result->rtyp = INT_CMD;
result->data = (char *)(long)(thread_id == 0L);
return FALSE;
}
LibThread::thread_id
VAR long thread_id
Definition shared.cc:225

## makeAtomicList()

BOOLEAN LibThread::makeAtomicList | ( | leftv | result,
|  | leftv | arg )

Definition at line 787 of file shared.cc.

{
if (wrong_num_args("makeAtomicList", arg, 1))
return TRUE;
if (not_a_uri("makeAtomicList", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = makeSharedObject(global_objects,
&global_objects_lock, type_atomic_list, uri, consList);
((TxList *) obj)->set_region(NULL);
result->rtyp = type_atomic_list;
result->data = new_shared(obj);
return FALSE;
}
LibThread::makeSharedObject
SharedObject * makeSharedObject(SharedObjectTable &table, Lock *lock, int type, string &name, SharedConstructor scons)
Definition shared.cc:244
LibThread::consList
SharedObject * consList()
Definition shared.cc:707

## makeAtomicTable()

BOOLEAN LibThread::makeAtomicTable | ( | leftv | result,
|  | leftv | arg )

Definition at line 773 of file shared.cc.

{
if (wrong_num_args("makeAtomicTable", arg, 1))
return TRUE;
if (not_a_uri("makeAtomicTable", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = makeSharedObject(global_objects,
&global_objects_lock, type_atomic_table, uri, consTable);
((TxTable *) obj)->set_region(NULL);
result->rtyp = type_atomic_table;
result->data = new_shared(obj);
return FALSE;
}
LibThread::consTable
SharedObject * consTable()
Definition shared.cc:703

## makeChannel()

BOOLEAN LibThread::makeChannel | ( | leftv | result,
|  | leftv | arg )

Definition at line 836 of file shared.cc.

{
if (wrong_num_args("makeChannel", arg, 1))
return TRUE;
if (not_a_uri("makeChannel", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = makeSharedObject(global_objects,
&global_objects_lock, type_channel, uri, consChannel);
result->rtyp = type_channel;
result->data = new_shared(obj);
return FALSE;
}
LibThread::consChannel
SharedObject * consChannel()
Definition shared.cc:711
LibThread::type_channel
int type_channel
Definition shared.cc:230

## makeRegion()

BOOLEAN LibThread::makeRegion | ( | leftv | result,
|  | leftv | arg )

Definition at line 862 of file shared.cc.

{
if (wrong_num_args("makeRegion", arg, 1))
return TRUE;
if (not_a_uri("makeRegion", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = makeSharedObject(global_objects,
&global_objects_lock, type_region, uri, consRegion);
result->rtyp = type_region;
result->data = new_shared(obj);
return FALSE;
}
LibThread::type_region
int type_region
Definition shared.cc:228
LibThread::consRegion
SharedObject * consRegion()
Definition shared.cc:719

## makeRegionlockType()

void LibThread::makeRegionlockType | ( | int & | type,
|  | const char * | name )

Definition at line 1316 of file shared.cc.

{
if (type != 0) return;
blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
b->blackbox_Init = shared_init;
b->blackbox_destroy = rlock_destroy;
b->blackbox_Copy = shared_copy;
b->blackbox_String = shared_string;
b->blackbox_Assign = rlock_assign;
b->blackbox_CheckAssign = shared_check_assign;
type = setBlackboxStuff(b, name);
installShared(type);
}
setBlackboxStuff
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
Definition blackbox.cc:143
b
CanonicalForm b
Definition cfModGcd.cc:4111
LibThread::shared_check_assign
BOOLEAN shared_check_assign(blackbox *b, leftv l, leftv r)
Definition shared.cc:568
LibThread::shared_init
void * shared_init(blackbox *b)
Definition shared.cc:482
LibThread::shared_copy
void * shared_copy(blackbox *b, void *d)
Definition shared.cc:510
LibThread::shared_string
char * shared_string(blackbox *b, void *d)
Definition shared.cc:590
LibThread::rlock_assign
BOOLEAN rlock_assign(leftv l, leftv r)
Definition shared.cc:544
LibThread::rlock_destroy
void rlock_destroy(blackbox *b, void *d)
Definition shared.cc:501
LibThread::installShared
void installShared(int type)
Definition shared.cc:1297
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## makeSharedList()

BOOLEAN LibThread::makeSharedList | ( | leftv | result,
|  | leftv | arg )

Definition at line 819 of file shared.cc.

{
if (wrong_num_args("makeSharedList", arg, 2))
return TRUE;
if (not_a_region("makeSharedList", arg))
return TRUE;
if (not_a_uri("makeSharedList", arg->next))
return TRUE;
Region *region = *(Region **) arg->Data();
string s = str(arg->next);
SharedObject *obj = makeSharedObject(region->objects,
region->get_lock(), type_shared_list, s, consList);
((TxList *) obj)->set_region(region);
result->rtyp = type_shared_list;
result->data = new_shared(obj);
return FALSE;
}
LibThread::Region::objects
SharedObjectTable objects
Definition shared.cc:204
LibThread::Region::get_lock
Lock * get_lock()
Definition shared.cc:207

## makeSharedObject()

SharedObject * LibThread::makeSharedObject | ( | SharedObjectTable & | table,
|  | Lock * | lock,
|  | int | type,
|  | string & | name,
|  | SharedConstructor | scons )

Definition at line 244 of file shared.cc.

{
int was_locked = lock->is_locked();
SharedObject *result = NULL;
if (!was_locked)
lock->lock();
if (table.count(name)) {
result = table[name];
if (result->get_type() != type)
result = NULL;
} else {
result = scons();
result->set_type(type);
result->set_name(name);
table.insert(pair<string,SharedObject *>(name, result));
}
if (!was_locked)
lock->unlock();
return result;
}

## makeSharedTable()

BOOLEAN LibThread::makeSharedTable | ( | leftv | result,
|  | leftv | arg )

Definition at line 801 of file shared.cc.

{
if (wrong_num_args("makeSharedTable", arg, 2))
return TRUE;
if (not_a_region("makeSharedTable", arg))
return TRUE;
if (not_a_uri("makeSharedTable", arg->next))
return TRUE;
Region *region = *(Region **) arg->Data();
fflush(stdout);
string s = str(arg->next);
SharedObject *obj = makeSharedObject(region->objects,
region->get_lock(), type_shared_table, s, consTable);
((TxTable *) obj)->set_region(region);
result->rtyp = type_shared_table;
result->data = new_shared(obj);
return FALSE;
}

## makeSharedType()

void LibThread::makeSharedType | ( | int & | type,
|  | const char * | name )

Definition at line 1301 of file shared.cc.

{
if (type != 0) return;
blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
b->blackbox_Init = shared_init;
b->blackbox_destroy = shared_destroy;
b->blackbox_Copy = shared_copy;
b->blackbox_String = shared_string;
b->blackbox_Assign = shared_assign;
b->blackbox_CheckAssign = shared_check_assign;
// b->blackbox_Op2 = shared_op2;
// b->blackbox_Op3 = shared_op3;
type = setBlackboxStuff(b, name);
installShared(type);
}
LibThread::shared_assign
BOOLEAN shared_assign(leftv l, leftv r)
Definition shared.cc:519
LibThread::shared_destroy
void shared_destroy(blackbox *b, void *d)
Definition shared.cc:493

## makeSyncVar()

BOOLEAN LibThread::makeSyncVar | ( | leftv | result,
|  | leftv | arg )

Definition at line 849 of file shared.cc.

{
if (wrong_num_args("makeSyncVar", arg, 1))
return TRUE;
if (not_a_uri("makeSyncVar", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = makeSharedObject(global_objects,
&global_objects_lock, type_syncvar, uri, consSyncVar);
result->rtyp = type_syncvar;
result->data = new_shared(obj);
return FALSE;
}
LibThread::consSyncVar
SharedObject * consSyncVar()
Definition shared.cc:715
LibThread::type_syncvar
int type_syncvar
Definition shared.cc:231

## new_shared()

void * LibThread::new_shared | ( | SharedObject * | obj | ) |

Definition at line 486 of file shared.cc.

{
acquireShared(obj);
void *result = omAlloc0(sizeof(SharedObject *));
*(SharedObject **)result = obj;
return result;
}

## newThread()

ThreadState * LibThread::newThread | ( | void *(* | thread_func )(ThreadState *, void *),
|  | void * | arg,
|  | const char ** | error )

static

Definition at line 1431 of file shared.cc.

{
ThreadState *ts = NULL;
if (error) *error = NULL;
thread_lock.lock();
for (int i=0; i<MAX_THREADS; i++) {
if (!thread_state[i].active) {
ts = thread_state + i;
ts->index = i;
ts->parent = pthread_self();
ts->active = true;
ts->running = true;
ts->to_thread = queue<string>();
ts->from_thread = queue<string>();
ts->thread_func = thread_func;
ts->arg = arg;
ts->result = NULL;
if (pthread_create(&ts->id, NULL, thread_main, ts)<0) {
if (error)
*error = "createThread: internal error: failed to create thread";
goto fail;
}
goto exit;
}
}
if (error) *error = "createThread: too many threads";
fail:
ts = NULL;
exit:
thread_lock.unlock();
return ts;
}
LibThread::ThreadState::thread_func
void *(* thread_func)(ThreadState *, void *)
Definition shared.cc:1336
LibThread::ThreadState::arg
void * arg
Definition shared.cc:1337
LibThread::thread_state
ThreadState * thread_state
Definition shared.cc:1361
LibThread::thread_main
void * thread_main(void *arg)
Definition shared.cc:1380
MAX_THREADS
#define MAX_THREADS
Definition shared.cc:1329

## not_a_region()

int LibThread::not_a_region | ( | const char * | name,
|  | leftv | arg )

Definition at line 690 of file shared.cc.

{
if (arg->Typ() != type_region || !arg->Data()) {
report("%s: not a region", name);
return TRUE;
}
return FALSE;
}
LibThread::report
void report(const char *fmt, const char *name)
Definition shared.cc:661

## not_a_uri()

int LibThread::not_a_uri | ( | const char * | name,
|  | leftv | arg )

Definition at line 682 of file shared.cc.

{
if (arg->Typ() != STRING_CMD) {
report("%s: not a valid URI", name);
return TRUE;
}
return FALSE;
}

## putList()

BOOLEAN LibThread::putList | ( | leftv | result,
|  | leftv | arg )

Definition at line 1056 of file shared.cc.

{
if (wrong_num_args("putList", arg, 3))
return TRUE;
if (arg->Typ() != type_atomic_list && arg->Typ() != type_shared_list) {
WerrorS("putList: not a valid list (shared or atomic)");
return TRUE;
}
if (arg->next->Typ() != INT_CMD) {
WerrorS("putList: index must be an integer");
return TRUE;
}
TxList *list = *(TxList **) arg->Data();
if (!list) {
WerrorS("putList: list has not been initialized");
return TRUE;
}
long index = (long)(arg->next->Data());
string value = LinTree::to_string(arg->next->next);
int success = list->put(index, value);
if (success < 0) {
WerrorS("putList: region not acquired");
return TRUE;
}
result->rtyp = NONE;
return FALSE;
}

## putTable()

BOOLEAN LibThread::putTable | ( | leftv | result,
|  | leftv | arg )

Definition at line 996 of file shared.cc.

{
if (wrong_num_args("putTable", arg, 3))
return TRUE;
if (arg->Typ() != type_atomic_table && arg->Typ() != type_shared_table) {
WerrorS("putTable: not a valid table");
return TRUE;
}
if (arg->next->Typ() != STRING_CMD) {
WerrorS("putTable: not a valid table key");
return TRUE;
}
TxTable *table = *(TxTable **) arg->Data();
if (!table) {
WerrorS("putTable: table has not been initialized");
return TRUE;
}
string key = (char *)(arg->next->Data());
string value = LinTree::to_string(arg->next->next);
int success = table->put(key, value);
if (success < 0) {
WerrorS("putTable: region not acquired");
return TRUE;
}
result->rtyp = NONE;
return FALSE;
}
LibThread::TxTable::put
int put(string &key, string &value)
Definition shared.cc:321

## readSyncVar()

BOOLEAN LibThread::readSyncVar | ( | leftv | result,
|  | leftv | arg )

Definition at line 1233 of file shared.cc.

{
if (wrong_num_args("readSyncVar", arg, 1))
return TRUE;
if (arg->Typ() != type_syncvar) {
WerrorS("readSyncVar: argument is not a syncvar");
return TRUE;
}
SingularSyncVar *syncvar = *(SingularSyncVar **)arg->Data();
if (!syncvar) {
WerrorS("readSyncVar: syncvar has not been initialized");
return TRUE;
}
string item = syncvar->read();
leftv val = LinTree::from_string(item);
result->rtyp = val->Typ();
result->data = val->Data();
return FALSE;
}
LibThread::SingularSyncVar::read
string read()
Definition shared.cc:466

## receiveChannel()

BOOLEAN LibThread::receiveChannel | ( | leftv | result,
|  | leftv | arg )

Definition at line 1147 of file shared.cc.

{
if (wrong_num_args("receiveChannel", arg, 1))
return TRUE;
if (arg->Typ() != type_channel) {
WerrorS("receiveChannel: argument is not a channel");
return TRUE;
}
SingularChannel *channel = *(SingularChannel **)arg->Data();
if (!channel) {
WerrorS("receiveChannel: channel has not been initialized");
return TRUE;
}
string item = channel->receive();
leftv val = LinTree::from_string(item);
result->rtyp = val->Typ();
result->data = val->Data();
return FALSE;
}
LibThread::SingularChannel::receive
string receive()
Definition shared.cc:406

## ref_shared()

void LibThread::ref_shared | ( | LinTree::LinTree & | lintree,
|  | int | by )

Definition at line 1285 of file shared.cc.

{
SharedObject *obj = lintree.get<SharedObject *>();
while (by > 0) {
obj->incref();
by--;
}
while (by < 0) {
obj->decref();
by++;
}
}
LibThread::SharedObject::decref
long decref()
Definition shared.cc:170

## regionLock()

BOOLEAN LibThread::regionLock | ( | leftv | result,
|  | leftv | arg )

Definition at line 1098 of file shared.cc.

{
if (wrong_num_args("lockRegion", arg, 1))
return TRUE;
if (not_a_region("lockRegion", arg))
return TRUE;
Region *region = *(Region **)arg->Data();
if (region->is_locked()) {
WerrorS("lockRegion: region is already locked");
return TRUE;
}
region->lock();
result->rtyp = type_regionlock;
result->data = new_shared(region);
return FALSE;
}
LibThread::type_regionlock
int type_regionlock
Definition shared.cc:229

## release() [1/2]

void LibThread::release | ( | Job * | job | ) |

## release() [2/2]

void LibThread::release | ( | ThreadPool * | pool | ) |

Definition at line 2232 of file shared.cc.

{
releaseShared(pool);
}
LibThread::releaseShared
void releaseShared(SharedObject *obj)
Definition shared.cc:192

## releaseShared()

void LibThread::releaseShared | ( | SharedObject * | obj | ) |

Definition at line 192 of file shared.cc.

{
if (obj->decref() == 0) {
// delete obj;
}
}

## report()

void LibThread::report | ( | const char * | fmt,
|  | const char * | name )

Definition at line 661 of file shared.cc.

{
char buf[80];
snprintf(buf,80, fmt, name);
WerrorS(buf);
}

## retain() [1/2]

void LibThread::retain | ( | Job * | job | ) |

## retain() [2/2]

void LibThread::retain | ( | ThreadPool * | pool | ) |

Definition at line 2236 of file shared.cc.

{
acquireShared(pool);
}

## rlock_assign()

BOOLEAN LibThread::rlock_assign | ( | leftv | l,
|  | leftv | r )

Definition at line 544 of file shared.cc.

{
if (r->Typ() == l->Typ()) {
if (l->rtyp == IDHDL) {
omFree(IDDATA((idhdl)l->data));
IDDATA((idhdl)l->data) = (char*)shared_copy(NULL,r->Data());
} else {
leftv ll=l->LData();
if (ll==NULL)
{
return TRUE; // out of array bounds or similiar
}
rlock_destroy(NULL, ll->data);
omFree(ll->data);
ll->data = shared_copy(NULL,r->Data());
}
} else {
Werror("assign %s(%d) = %s(%d)",
Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ());
return TRUE;
}
return FALSE;
}
Tok2Cmdname
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
IDDATA
#define IDDATA(a)
Definition ipid.h:126
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
idhdl
idrec * idhdl
Definition ring.h:22
IDHDL
#define IDHDL
Definition tok.h:31

## rlock_destroy()

void LibThread::rlock_destroy | ( | blackbox * | b,
|  | void * | d )

Definition at line 501 of file shared.cc.

{
SharedObject *obj = *(SharedObject **)d;
((Region *) obj)->unlock();
if (obj) {
releaseShared(*(SharedObject **)d);
*(SharedObject **)d = NULL;
}
}

## rlock_string()

char * LibThread::rlock_string | ( | blackbox * | b,
|  | void * | d )

Definition at line 652 of file shared.cc.

{
char buf[80];
SharedObject *obj = *(SharedObject **)d;
if (!obj)
return omStrDup("<uninitialized region lock>");
snprintf(buf,80, "<region lock \"%.40s\">", obj->get_name().c_str());
return omStrDup(buf);
}

## scheduleJob()

BOOLEAN LibThread::scheduleJob | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2789 of file shared.cc.

{
vector<Job *> jobs;
vector<Job *> deps;
Command cmd("scheduleJob", result, arg);
cmd.check_argc_min(1);
int has_pool = cmd.test_arg(0, type_threadpool);
if (has_pool) {
cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
cmd.check_init(0, "threadpool not initialized");
}
cmd.check_argc_min(has_pool+1);
int has_prio = cmd.test_arg(has_pool, INT_CMD);
ThreadPool *pool;
if (has_pool)
pool = cmd.shared_arg<ThreadPool>(0);
else {
if (!currentThreadPoolRef)
return cmd.abort("no current threadpool defined");
pool = currentThreadPoolRef;
}
long prio = has_prio ? (long) cmd.arg(has_pool) : 0L;
int first_arg = has_pool + has_prio;
if (cmd.test_arg(first_arg, type_job)) {
jobs.push_back(*(Job **)(cmd.arg(first_arg)));
} else if (cmd.test_arg(first_arg, STRING_CMD)) {
jobs.push_back(new ProcJob((char *)(cmd.arg(first_arg))));
} else if (cmd.test_arg(first_arg, LIST_CMD)) {
lists l = (lists) (cmd.arg(first_arg));
int n = lSize(l);
for (int i = 0; i < n; i++) {
if (l->m[i].Typ() != type_job)
return cmd.abort("job argument must be a job, string, or list of jobs");
}
for (int i = 0; i < n; i++) {
Job *job = *(Job **) (l->m[i].Data());
if (!job)
return cmd.abort("job not initialized");
jobs.push_back(job);
}
} else {
return cmd.abort("job argument must be a job, string, or list of jobs");
}
bool error = false;
leftv a = arg->next;
if (has_pool) a = a->next;
if (has_prio) a = a->next;
for (; !error && a; a = a->next) {
if (a->Typ() == type_job || a->Typ() == type_trigger) {
deps.push_back(*(Job **)(a->Data()));
} else if (a->Typ() == LIST_CMD) {
lists l = (lists) a->Data();
int n = lSize(l);
for (int i = 0; i < n; i++) {
if (l->m[i].Typ() == type_job || l->m[i].Typ() == type_trigger) {
deps.push_back(*(Job **)(l->m[i].Data()));
} else {
error = true;
break;
}
}
}
}
if (error) {
return cmd.abort("illegal dependency");
}
for (unsigned i = 0; i < jobs.size(); i++) {
Job *job = jobs[i];
if (job->pool) {
return cmd.abort("job has already been scheduled");
}
job->prio = prio;
}
for (unsigned i = 0; i < deps.size(); i++) {
Job *job = deps[i];
if (!job->pool) {
return cmd.abort("dependency has not yet been scheduled");
}
if (job->pool != pool) {
return cmd.abort("dependency has been scheduled on a different threadpool");
}
}
pool->scheduler->lock.lock();
bool cancelled = false;
for (unsigned i = 0; i < jobs.size(); i++) {
jobs[i]->addDep(deps);
}
for (unsigned i = 0; i < deps.size(); i++) {
deps[i]->addNotify(jobs);
cancelled |= deps[i]->cancelled;
}
for (unsigned i = 0; i < jobs.size(); i++) {
if (cancelled) {
jobs[i]->pool = pool;
pool->cancelJob(jobs[i]);
}
else
pool->attachJob(jobs[i]);
}
pool->scheduler->lock.unlock();
if (jobs.size() > 0)
cmd.set_result(type_job, new_shared(jobs[0]));
return cmd.status();
}
LibThread::Job::prio
long prio
Definition shared.cc:1547

## sendChannel()

BOOLEAN LibThread::sendChannel | ( | leftv | result,
|  | leftv | arg )

Definition at line 1130 of file shared.cc.

{
if (wrong_num_args("sendChannel", arg, 2))
return TRUE;
if (arg->Typ() != type_channel) {
WerrorS("sendChannel: argument is not a channel");
return TRUE;
}
SingularChannel *channel = *(SingularChannel **)arg->Data();
if (!channel) {
WerrorS("sendChannel: channel has not been initialized");
return TRUE;
}
channel->send(LinTree::to_string(arg->next));
result->rtyp = NONE;
return FALSE;
}
LibThread::SingularChannel::send
void send(string item)
Definition shared.cc:400

## setCurrentThreadPool()

BOOLEAN LibThread::setCurrentThreadPool | ( | leftv | result,
|  | leftv | arg )

Definition at line 2341 of file shared.cc.

{
Command cmd("setCurrentThreadPool", result, arg);
cmd.check_argc(1);
cmd.check_init(0, "threadpool not initialized");
if (cmd.ok()) {
ThreadPool *pool = *(ThreadPool **)(cmd.arg(0));
acquireShared(pool);
if (currentThreadPoolRef)
releaseShared(currentThreadPoolRef);
currentThreadPoolRef = pool;
}
return cmd.status();
}

## setJobData()

void LibThread::setJobData | ( | Job * | job,
|  | void * | data )

Definition at line 2644 of file shared.cc.

{
ThreadPool *pool = job->pool;
if (pool) pool->scheduler->lock.lock();
job->data = data;
if (pool) pool->scheduler->lock.unlock();
}

## setJobName() [1/2]

void LibThread::setJobName | ( | const char * |  | ) |

## setJobName() [2/2]

void LibThread::setJobName | ( | Job * | job,
|  | const char * | name )

Definition at line 2683 of file shared.cc.

{
// TODO
}

## setOption()

void LibThread::setOption | ( | int | ch | ) |

Definition at line 1363 of file shared.cc.

{
int index = feGetOptIndex(ch);
feSetOptValue((feOptIndex) index, (int) 1);
}
feOptIndex
feOptIndex
Definition feOptGen.h:15
feGetOptIndex
feOptIndex feGetOptIndex(const char *name)
Definition feOpt.cc:104
feSetOptValue
const char * feSetOptValue(feOptIndex opt, char *optarg)
Definition feOpt.cc:154

## setSharedName()

BOOLEAN LibThread::setSharedName | ( | leftv | result,
|  | leftv | arg )

Definition at line 3033 of file shared.cc.

{
Command cmd("setSharedName", result, arg);
cmd.check_argc(2);
int type = cmd.argtype(0);
cmd.check_init(0, "first argument is not initialized");
if (type != type_job && type != type_trigger && type != type_threadpool) {
cmd.report("first argument must be a job, trigger, or threadpool");
}
cmd.check_arg(1, STRING_CMD, "second argument must be a string");
if (cmd.ok()) {
SharedObject *obj = cmd.shared_arg<SharedObject>(0);
name_lock.lock();
obj->set_name((char *) cmd.arg(1));
name_lock.unlock();
}
return cmd.status();
}
LibThread::SharedObject::set_name
void set_name(std::string &name_init)
Definition shared.cc:160

## setThreadPoolConcurrency()

BOOLEAN LibThread::setThreadPoolConcurrency | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2291 of file shared.cc.

{
Command cmd("setThreadPoolWorkers", result, arg);
cmd.check_argc(2);
cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
cmd.check_arg(1, INT_CMD, "second argument must be an integer");
cmd.check_init(0, "threadpool not initialized");
if (cmd.ok()) {
ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
Scheduler *sched = pool->scheduler;
sched->lock.lock();
sched->set_maxconcurrency(cmd.int_arg(1));
sched->lock.unlock();
cmd.no_result();
}
return cmd.status();
}

## setThreadPoolWorkers()

BOOLEAN LibThread::setThreadPoolWorkers | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2261 of file shared.cc.

{
Command cmd("setThreadPoolWorkers", result, arg);
cmd.check_argc(2);
cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
cmd.check_arg(1, INT_CMD, "second argument must be an integer");
cmd.check_init(0, "threadpool not initialized");
if (cmd.ok()) {
ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
Scheduler *sched = pool->scheduler;
// TODO: count/add threads
cmd.no_result();
}
return cmd.status();
}

## shared_alloc() [1/2]

template<typename T>

T * LibThread::shared_alloc | ( | size_t | n | ) |

Definition at line 42 of file thread.cc.

{
T *p = (T *) malloc(n * sizeof(T));
return p;
}
p
int p
Definition cfModGcd.cc:4086
T
STATIC_VAR jList * T
Definition janet.cc:30
malloc
#define malloc
Definition omAllocFunc.c:12

## shared_alloc() [2/2]

template<typename T>

T * LibThread::shared_alloc | ( | std::size_t | n | ) |

## shared_alloc0() [1/2]

template<typename T>

T * LibThread::shared_alloc0 | ( | size_t | n | ) |

Definition at line 47 of file thread.cc.

{
T *p = (T *) calloc(n, sizeof(T));
return p;
}
calloc
#define calloc
Definition omAllocFunc.c:13

## shared_alloc0() [2/2]

template<typename T>

T * LibThread::shared_alloc0 | ( | std::size_t | n | ) |

## shared_assign()

BOOLEAN LibThread::shared_assign | ( | leftv | l,
|  | leftv | r )

Definition at line 519 of file shared.cc.

{
if (r->Typ() == l->Typ()) {
if (l->rtyp == IDHDL) {
omFree(IDDATA((idhdl)l->data));
IDDATA((idhdl)l->data) = (char*)shared_copy(NULL,r->Data());
} else {
leftv ll=l->LData();
if (ll==NULL)
{
return TRUE; // out of array bounds or similiar
}
if (ll->data) {
shared_destroy(NULL, ll->data);
omFree(ll->data);
}
ll->data = shared_copy(NULL,r->Data());
}
} else {
Werror("assign %s(%d) = %s(%d)",
Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ());
return TRUE;
}
return FALSE;
}

## shared_check_assign()

BOOLEAN LibThread::shared_check_assign | ( | blackbox * | b,
|  | leftv | l,
|  | leftv | r )

Definition at line 568 of file shared.cc.

{
int lt = l->Typ();
int rt = r->Typ();
if (lt != DEF_CMD && lt != rt) {
const char *rn=Tok2Cmdname(rt);
const char *ln=Tok2Cmdname(lt);
Werror("cannot assign %s (%d) to %s (%d)\n", rn, rt, ln, lt);
return TRUE;
}
return FALSE;
}
DEF_CMD
@ DEF_CMD
Definition tok.h:58

## shared_copy()

void * LibThread::shared_copy | ( | blackbox * | b,
|  | void * | d )

Definition at line 510 of file shared.cc.

{
SharedObject *obj = *(SharedObject **)d;
void *result = shared_init(b);
*(SharedObject **)result = obj;
if (obj)
acquireShared(obj);
return result;
}

## shared_destroy()

void LibThread::shared_destroy | ( | blackbox * | b,
|  | void * | d )

Definition at line 493 of file shared.cc.

{
SharedObject *obj = *(SharedObject **)d;
if (obj) {
releaseShared(*(SharedObject **)d);
*(SharedObject **)d = NULL;
}
}

## shared_free() [1/2]

template<typename T>

T LibThread::shared_free | ( | T * | p | ) |

Definition at line 52 of file thread.cc.

{
free(p);
}
free
#define free
Definition omAllocFunc.c:14

## shared_free() [2/2]

template<typename T>

void LibThread::shared_free | ( | T * | p | ) |

Definition at line 52 of file thread.cc.

{
free(p);
}

## shared_init()

void * LibThread::shared_init | ( | blackbox * | b | ) |

Definition at line 482 of file shared.cc.

{
return omAlloc0(sizeof(SharedObject *));
}

## shared_op2()

BOOLEAN LibThread::shared_op2 | ( | int | op,
|  | leftv | res,
|  | leftv | a1,
|  | leftv | a2 )

Definition at line 580 of file shared.cc.

{
SharedObject *obj = *(SharedObject **)a1->Data();
return obj->op2(op, res, a1, a2);
}
LibThread::SharedObject::op2
virtual BOOLEAN op2(int op, leftv res, leftv a1, leftv a2)
Definition shared.cc:180
res
CanonicalForm res
Definition facAbsFact.cc:60

## shared_op3()

BOOLEAN LibThread::shared_op3 | ( | int | op,
|  | leftv | res,
|  | leftv | a1,
|  | leftv | a2,
|  | leftv | a3 )

Definition at line 585 of file shared.cc.

{
SharedObject *obj = *(SharedObject **)a1->Data();
return obj->op3(op, res, a1, a2, a3);
}
LibThread::SharedObject::op3
virtual BOOLEAN op3(int op, leftv res, leftv a1, leftv a2, leftv a3)
Definition shared.cc:183

## shared_string()

char * LibThread::shared_string | ( | blackbox * | b,
|  | void * | d )

Definition at line 590 of file shared.cc.

{
char buf[80];
SharedObject *obj = *(SharedObject **)d;
if (!obj)
return omStrDup("<uninitialized shared object>");
int type = obj->get_type();
string &name = obj->get_name();
const char *type_name = "unknown";
if (type == type_channel)
type_name = "channel";
else if (type == type_atomic_table)
type_name = "atomic_table";
else if (type == type_shared_table)
type_name = "shared_table";
else if (type == type_atomic_list)
type_name = "atomic_list";
else if (type == type_shared_list)
type_name = "shared_list";
else if (type == type_syncvar)
type_name = "syncvar";
else if (type == type_region)
type_name = "region";
else if (type == type_regionlock)
type_name = "regionlock";
else if (type == type_thread) {
snprintf(buf,80, "<thread #%s>", name.c_str());
return omStrDup(buf);
}
else if (type == type_threadpool) {
if (name.size() > 0) {
name_lock.lock();
snprintf(buf,80, "<threadpool \"%.40s\"@%p>", name.c_str(), obj);
name_lock.unlock();
} else
snprintf(buf,80, "<threadpool @%p>", obj);
return omStrDup(buf);
}
else if (type == type_job) {
if (name.size() > 0) {
name_lock.lock();
snprintf(buf,80, "<job \"%.40s\"@%p>", name.c_str(), obj);
name_lock.unlock();
} else
snprintf(buf,80, "<job @%p>", obj);
return omStrDup(buf);
}
else if (type == type_trigger) {
if (name.size() > 0) {
name_lock.lock();
snprintf(buf,80, "<trigger \"%.40s\"@%p>", name.c_str(), obj);
name_lock.unlock();
} else
snprintf(buf,80, "<trigger @%p>", obj);
return omStrDup(buf);
} else {
snprintf(buf,80, "<unknown type %d>", type);
return omStrDup(buf);
}
snprintf(buf,80, "<%s \"%.40s\">", type_name, name.c_str());
return omStrDup(buf);
}

## startJob() [1/3]

BOOLEAN LibThread::startJob | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2518 of file shared.cc.

{
Command cmd("startJob", result, arg);
cmd.check_argc_min(1);
int has_pool = cmd.test_arg(0, type_threadpool);
cmd.check_argc_min(1+has_pool);
if (has_pool)
cmd.check_init(0, "threadpool not initialized");
int has_prio = cmd.test_arg(has_pool, INT_CMD);
long prio = has_prio ? (long) cmd.arg(has_pool) : 0L;
int first_arg = has_pool + has_prio;
cmd.check_arg(first_arg, type_job, STRING_CMD,
"job argument must be a job or string");
if (cmd.ok() && cmd.argtype(first_arg) == type_job)
cmd.check_init(first_arg, "job not initialized");
if (!cmd.ok()) return cmd.status();
ThreadPool *pool;
if (has_pool)
pool = cmd.shared_arg<ThreadPool>(0);
else {
if (!currentThreadPoolRef)
return cmd.abort("no current threadpool defined");
pool = currentThreadPoolRef;
}
Job *job;
if (cmd.argtype(first_arg) == type_job)
job = *(Job **)(cmd.arg(first_arg));
else
job = new ProcJob((char *)(cmd.arg(first_arg)));
leftv a = arg->next;
if (has_pool) a = a->next;
if (has_prio) a = a->next;
for (; a != NULL; a = a->next) {
job->args.push_back(LinTree::to_string(a));
}
if (job->pool)
return cmd.abort("job has already been scheduled");
job->prio = prio;
pool->attachJob(job);
cmd.set_result(type_job, new_shared(job));
return cmd.status();
}

## startJob() [2/3]

Job * LibThread::startJob | ( | ThreadPool * | pool,
|  | Job * | job )

Definition at line 2486 of file shared.cc.

{
return startJob(pool, job, NULL);
}
LibThread::startJob
Job * startJob(ThreadPool *pool, Job *job, leftv arg)
Definition shared.cc:2476

## startJob() [3/3]

Job * LibThread::startJob | ( | ThreadPool * | pool,
|  | Job * | job,
|  | leftv | arg )

Definition at line 2476 of file shared.cc.

{
if (job->pool) return NULL;
while (arg) {
job->args.push_back(LinTree::to_string(arg));
arg = arg->next;
}
pool->attachJob(job);
return job;
}

## statChannel()

BOOLEAN LibThread::statChannel | ( | leftv | result,
|  | leftv | arg )

Definition at line 1166 of file shared.cc.

{
if (wrong_num_args("statChannel", arg, 1))
return TRUE;
if (arg->Typ() != type_channel) {
WerrorS("statChannel: argument is not a channel");
return TRUE;
}
SingularChannel *channel = *(SingularChannel **)arg->Data();
if (!channel) {
WerrorS("receiveChannel: channel has not been initialized");
return TRUE;
}
long n = channel->count();
result->rtyp = INT_CMD;
result->data = (char *)n;
return FALSE;
}
LibThread::SingularChannel::count
long count()
Definition shared.cc:418

## statSyncVar()

BOOLEAN LibThread::statSyncVar | ( | leftv | result,
|  | leftv | arg )

Definition at line 1252 of file shared.cc.

{
if (wrong_num_args("statSyncVar", arg, 1))
return TRUE;
if (arg->Typ() != type_syncvar) {
WerrorS("statSyncVar: argument is not a syncvar");
return TRUE;
}
SingularSyncVar *syncvar = *(SingularSyncVar **)arg->Data();
if (!syncvar) {
WerrorS("statSyncVar: syncvar has not been initialized");
return TRUE;
}
int init = syncvar->check();
result->rtyp = INT_CMD;
result->data = (char *)(long) init;
return FALSE;
}
LibThread::SingularSyncVar::check
int check()
Definition shared.cc:474
LinTree::init
void init()
Definition lintree.cc:864

## str()

char * LibThread::str | ( | leftv | arg | ) |

Definition at line 699 of file shared.cc.

{
return (char *)(arg->Data());
}

## testTrigger()

BOOLEAN LibThread::testTrigger | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2773 of file shared.cc.

{
Command cmd("testTrigger", result, arg);
cmd.check_argc(1);
cmd.check_arg(0, type_trigger, "argument must be a trigger");
cmd.check_init(0, "trigger not initialized");
if (cmd.ok()) {
Trigger *trigger = cmd.shared_arg<Trigger>(0);
ThreadPool *pool = trigger->pool;
pool->scheduler->lock.lock();
cmd.set_result((long)trigger->ready());
pool->scheduler->lock.unlock();
}
return cmd.status();
}
LibThread::Job::ready
virtual bool ready()
Definition shared.cc:1600

## thread_init()

void LibThread::thread_init | ( |  | ) |

Definition at line 1368 of file shared.cc.

{
master_lock.lock();
thread_id = ++thread_counter;
master_lock.unlock();
#ifdef ENABLE_THREADS
pSingular_initialize_thread();
siInit(global_argv0);
#endif
setOption('q');
// setOption('b');
}
siInit
void siInit(char *)
Definition misc_ip.cc:1364
LibThread::thread_counter
long thread_counter
Definition shared.cc:226
LibThread::setOption
void setOption(int ch)
Definition shared.cc:1363
LibThread::master_lock
Lock master_lock(true)
pSingular_initialize_thread
void pSingular_initialize_thread()

## thread_main()

void * LibThread::thread_main | ( | void * | arg | ) |

Definition at line 1380 of file shared.cc.

{
ThreadState *ts = (ThreadState *)arg;
thread_init();
return ts->thread_func(ts, ts->arg);
}
LibThread::thread_init
void thread_init()
Definition shared.cc:1368

## threadEval()

BOOLEAN LibThread::threadEval | ( | leftv | result,
|  | leftv | arg )

Definition at line 2922 of file shared.cc.

{
if (wrong_num_args("threadEval", arg, 2))
return TRUE;
if (arg->Typ() != type_thread) {
WerrorS("threadEval: argument is not a thread");
return TRUE;
}
InterpreterThread *thread = *(InterpreterThread **)arg->Data();
string expr = LinTree::to_string(arg->next);
ThreadState *ts = thread->getThreadState();
if (ts && ts->parent != pthread_self()) {
WerrorS("threadEval: can only be called from parent thread");
return TRUE;
}
if (ts) ts->lock.lock();
if (!ts || !ts->running || !ts->active) {
WerrorS("threadEval: thread is no longer running");
if (ts) ts->lock.unlock();
return TRUE;
}
ts->to_thread.push("e");
ts->to_thread.push(expr);
ts->to_cond.signal();
ts->lock.unlock();
result->rtyp = NONE;
return FALSE;
}

## threadExec()

BOOLEAN LibThread::threadExec | ( | leftv | result,
|  | leftv | arg )

Definition at line 2950 of file shared.cc.

{
if (wrong_num_args("threadExec", arg, 2))
return TRUE;
if (arg->Typ() != type_thread) {
WerrorS("threadExec: argument is not a thread");
return TRUE;
}
InterpreterThread *thread = *(InterpreterThread **)arg->Data();
string expr = LinTree::to_string(arg->next);
ThreadState *ts = thread->getThreadState();
if (ts && ts->parent != pthread_self()) {
WerrorS("threadExec: can only be called from parent thread");
return TRUE;
}
if (ts) ts->lock.lock();
if (!ts || !ts->running || !ts->active) {
WerrorS("threadExec: thread is no longer running");
if (ts) ts->lock.unlock();
return TRUE;
}
ts->to_thread.push("x");
ts->to_thread.push(expr);
ts->to_cond.signal();
ts->lock.unlock();
result->rtyp = NONE;
return FALSE;
}

## threadID()

BOOLEAN LibThread::threadID | ( | leftv | result,
|  | leftv | arg )

Definition at line 2906 of file shared.cc.

{
if (wrong_num_args("threadID", arg, 0))
return TRUE;
result->rtyp = INT_CMD;
result->data = (char *)thread_id;
return FALSE;
}

## threadPoolExec()

BOOLEAN LibThread::threadPoolExec | ( | leftv | result,
|  | leftv | arg )

Definition at line 2978 of file shared.cc.

{
Command cmd("threadPoolExec", result, arg);
ThreadPool *pool;
cmd.check_argc(1, 2);
int has_pool = cmd.nargs() == 2;
if (has_pool) {
cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
cmd.check_init(0, "threadpool not initialized");
pool = cmd.shared_arg<ThreadPool>(0);
} else {
pool = currentThreadPoolRef;
if (!pool)
return cmd.abort("no current threadpool");
}
if (cmd.ok()) {
string expr = LinTree::to_string(has_pool ? arg->next : arg);
Job* job = new ExecJob();
job->args.push_back(expr);
job->pool = pool;
pool->broadcastJob(job);
}
return cmd.status();
}
LibThread::ExecJob
Definition shared.cc:2366
LibThread::ThreadPool::broadcastJob
void broadcastJob(Job *job)
Definition shared.cc:1937

## threadResult()

BOOLEAN LibThread::threadResult | ( | leftv | result,
|  | leftv | arg )

Definition at line 3002 of file shared.cc.

{
if (wrong_num_args("threadResult", arg, 1))
return TRUE;
if (arg->Typ() != type_thread) {
WerrorS("threadResult: argument is not a thread");
return TRUE;
}
InterpreterThread *thread = *(InterpreterThread **)arg->Data();
ThreadState *ts = thread->getThreadState();
if (ts && ts->parent != pthread_self()) {
WerrorS("threadResult: can only be called from parent thread");
return TRUE;
}
if (ts) ts->lock.lock();
if (!ts || !ts->running || !ts->active) {
WerrorS("threadResult: thread is no longer running");
if (ts) ts->lock.unlock();
return TRUE;
}
while (ts->from_thread.empty()) {
ts->from_cond.wait();
}
string expr = ts->from_thread.front();
ts->from_thread.pop();
ts->lock.unlock();
leftv val = LinTree::from_string(expr);
result->rtyp = val->Typ();
result->data = val->Data();
return FALSE;
}

## typeSharedObject()

BOOLEAN LibThread::typeSharedObject | ( | leftv | result,
|  | leftv | arg )

Definition at line 888 of file shared.cc.

{
if (wrong_num_args("findSharedObject", arg, 1))
return TRUE;
if (not_a_uri("findSharedObject", arg))
return TRUE;
string uri = str(arg);
SharedObject *obj = findSharedObject(global_objects,
&global_objects_lock, uri);
int type = obj ? obj->get_type() : -1;
const char *type_name = "undefined";
if (type == type_channel)
type_name = "channel";
else if (type == type_atomic_table)
type_name = "atomic_table";
else if (type == type_shared_table)
type_name = "shared_table";
else if (type == type_atomic_list)
type_name = "atomic_list";
else if (type == type_shared_list)
type_name = "shared_list";
else if (type == type_syncvar)
type_name = "syncvar";
else if (type == type_region)
type_name = "region";
else if (type == type_regionlock)
type_name = "regionlock";
result->rtyp = STRING_CMD;
result->data = (char *)(omStrDup(type_name));
return FALSE;
}

## unlockRegion()

BOOLEAN LibThread::unlockRegion | ( | leftv | result,
|  | leftv | arg )

Definition at line 1115 of file shared.cc.

{
if (wrong_num_args("unlockRegion", arg, 1))
return TRUE;
if (not_a_region("unlockRegion", arg))
return TRUE;
Region *region = *(Region **)arg->Data();
if (!region->is_locked()) {
WerrorS("unlockRegion: region is not locked");
return TRUE;
}
region->unlock();
result->rtyp = NONE;
return FALSE;
}
LibThread::Region::unlock
void unlock()
Definition shared.cc:212

## updateSyncVar()

BOOLEAN LibThread::updateSyncVar | ( | leftv | result,
|  | leftv | arg )

Definition at line 1204 of file shared.cc.

{
Command cmd("updateSyncVar", result, arg);
cmd.check_argc_min(2);
cmd.check_arg(0, type_syncvar, "first argument must be a syncvar");
cmd.check_init(0, "syncvar has not been initialized");
cmd.check_arg(1, STRING_CMD, "second argument must be a string");
if (cmd.ok()) {
SingularSyncVar *syncvar = cmd.shared_arg<SingularSyncVar>(0);
char *procname = (char *) cmd.arg(1);
arg = arg->next->next;
syncvar->acquire();
syncvar->wait_init();
vector<leftv> argv;
appendArg(argv, syncvar->get());
while (arg) {
appendArgCopy(argv, arg);
arg = arg->next;
}
int error = executeProc(*result, procname, argv);
if (!error) {
syncvar->update(result);
}
syncvar->release();
return error;
}
return cmd.status();
}
LibThread::SingularSyncVar::acquire
void acquire()
Definition shared.cc:435
LibThread::SingularSyncVar::wait_init
void wait_init()
Definition shared.cc:441
LibThread::SingularSyncVar::get
leftv get()
Definition shared.cc:445
LibThread::SingularSyncVar::update
void update(leftv val)
Definition shared.cc:449
LibThread::SingularSyncVar::release
void release()
Definition shared.cc:438
LibThread::appendArgCopy
static void appendArgCopy(vector< leftv > &argv, leftv arg)
Definition shared.cc:737
LibThread::appendArg
static void appendArg(vector< leftv > &argv, string &s)
Definition shared.cc:723
LibThread::executeProc
static BOOLEAN executeProc(sleftv &result, const char *procname, const vector< leftv > &argv)
Definition shared.cc:744

## updateTrigger()

BOOLEAN LibThread::updateTrigger | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2730 of file shared.cc.

{
Command cmd("updateTrigger", result, arg);
cmd.check_argc_min(1);
cmd.check_arg(0, type_trigger, "first argument must be a trigger");
cmd.check_init(0, "trigger not initialized");
if (cmd.ok()) {
Trigger *trigger = cmd.shared_arg<Trigger>(0);
trigger->pool->scheduler->lock.lock();
if (!trigger->accept(arg->next))
cmd.report("incompatible argument type(s) for this trigger");
else {
trigger->activate(arg->next);
if (trigger->ready()) {
trigger->run();
Scheduler::notifyDeps(trigger->pool->scheduler, trigger);
}
}
trigger->pool->scheduler->lock.unlock();
}
return cmd.status();
}
LibThread::Job::run
void run()
Definition shared.cc:1977
LibThread::Scheduler::notifyDeps
static void notifyDeps(Scheduler *scheduler, Job *job)
Definition shared.cc:1824
LibThread::Trigger::activate
virtual void activate(leftv arg)=0
LibThread::Trigger::accept
virtual bool accept(leftv arg)=0

## waitJob() [1/2]

void LibThread::waitJob | ( | Job * | job | ) |

Definition at line 2585 of file shared.cc.

{
assert(job->pool != NULL);
job->pool->waitJob(job);
}
LibThread::ThreadPool::waitJob
void waitJob(Job *job)
Definition shared.cc:1946
assert
#define assert(A)
Definition svd_si.h:3

## waitJob() [2/2]

BOOLEAN LibThread::waitJob | ( | leftv | result,
|  | leftv | arg )

static

Definition at line 2560 of file shared.cc.

{
Command cmd("waitJob", result, arg);
cmd.check_argc(1);
cmd.check_arg(0, type_job, "argument must be a job");
cmd.check_init(0, "job not initialized");
if (cmd.ok()) {
Job *job = *(Job **)(cmd.arg(0));
ThreadPool *pool = job->pool;
if (!pool) {
return cmd.abort("job has not yet been started or scheduled");
}
pool->waitJob(job);
if (job->cancelled) {
return cmd.abort("job has been cancelled");
}
if (job->result.size() == 0)
cmd.no_result();
else {
leftv res = LinTree::from_string(job->result);
cmd.set_result(res->Typ(), res->Data());
}
}
return cmd.status();
}

## writeSyncVar()

BOOLEAN LibThread::writeSyncVar | ( | leftv | result,
|  | leftv | arg )

Definition at line 1184 of file shared.cc.

{
if (wrong_num_args("writeSyncVar", arg, 2))
return TRUE;
if (arg->Typ() != type_syncvar) {
WerrorS("writeSyncVar: argument is not a syncvar");
return TRUE;
}
SingularSyncVar *syncvar = *(SingularSyncVar **)arg->Data();
if (!syncvar) {
WerrorS("writeSyncVar: syncvar has not been initialized");
return TRUE;
}
if (!syncvar->write(LinTree::to_string(arg->next))) {
WerrorS("writeSyncVar: variable already has a value");
return TRUE;
}
result->rtyp = NONE;
return FALSE;
}
LibThread::SingularSyncVar::write
int write(string item)
Definition shared.cc:454

## wrong_num_args()

int LibThread::wrong_num_args | ( | const char * | name,
|  | leftv | arg,
|  | int | n )

Definition at line 667 of file shared.cc.

{
for (int i=1; i<=n; i++) {
if (!arg) {
report("%s: too few arguments", name);
return TRUE;
}
arg = arg->next;
}
if (arg) {
report("%s: too many arguments", name);
return TRUE;
}
return FALSE;
}

## Variable Documentation

## currentJobRef

STATIC_VAR Job* LibThread::currentJobRef

Definition at line 1626 of file shared.cc.

## currentThreadPoolRef

STATIC_VAR ThreadPool* LibThread::currentThreadPoolRef

Definition at line 1625 of file shared.cc.

## global_objects

SharedObjectTable LibThread::global_objects

Definition at line 222 of file shared.cc.

## global_objects_lock

Lock LibThread::global_objects_lock

Definition at line 221 of file shared.cc.

## have_threads

const int LibThread::have_threads = 0

Definition at line 33 of file shared.cc.

## master_lock

Lock LibThread::master_lock(true) | ( | true |  | ) |

## name_lock

Lock LibThread::name_lock(true) | ( | true |  | ) |

## thread_counter

long LibThread::thread_counter

Definition at line 226 of file shared.cc.

## thread_id

VAR long LibThread::thread_id

Definition at line 225 of file shared.cc.

## thread_lock

Lock LibThread::thread_lock

Definition at line 1359 of file shared.cc.

## thread_state

ThreadState* LibThread::thread_state

Definition at line 1361 of file shared.cc.

## type_atomic_list

int LibThread::type_atomic_list

Definition at line 234 of file shared.cc.

## type_atomic_table

int LibThread::type_atomic_table

Definition at line 232 of file shared.cc.

## type_channel

int LibThread::type_channel

Definition at line 230 of file shared.cc.

## type_job

int LibThread::type_job

Definition at line 238 of file shared.cc.

## type_region

int LibThread::type_region

Definition at line 228 of file shared.cc.

## type_regionlock

int LibThread::type_regionlock

Definition at line 229 of file shared.cc.

## type_shared_list

int LibThread::type_shared_list

Definition at line 235 of file shared.cc.

## type_shared_table

int LibThread::type_shared_table

Definition at line 233 of file shared.cc.

## type_syncvar

int LibThread::type_syncvar

Definition at line 231 of file shared.cc.

## type_thread

int LibThread::type_thread

Definition at line 236 of file shared.cc.

## type_threadpool

int LibThread::type_threadpool

Definition at line 237 of file shared.cc.

## type_trigger

int LibThread::type_trigger

Definition at line 239 of file shared.cc.