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

Data Structures

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

Typedefs

typedef std::map< std::string, SharedObject * > SharedObjectTable
 
typedef SharedObjectSharedObjectPtr
 
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)
 
ThreadPoolcreateThreadPool (int threads, int prioThreads=0)
 
void closeThreadPool (ThreadPool *pool, bool wait)
 
ThreadPoolgetCurrentThreadPool ()
 
JobcreateJob (void(*func)(leftv result, leftv arg))
 
JobcreateJob (void(*func)(long ndeps, Job **deps))
 
JobgetCurrentJob ()
 
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 *)
 
JobstartJob (ThreadPool *pool, Job *job, leftv arg)
 
JobstartJob (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)
 
SharedObjectmakeSharedObject (SharedObjectTable &table, Lock *lock, int type, string &name, SharedConstructor scons)
 
SharedObjectfindSharedObject (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)
 
SharedObjectconsTable ()
 
SharedObjectconsList ()
 
SharedObjectconsChannel ()
 
SharedObjectconsSyncVar ()
 
SharedObjectconsRegion ()
 
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 ThreadStatenewThread (void *(*thread_func)(ThreadState *, void *), void *arg, const char **error)
 
ThreadStatecreateThread (void *(*thread_func)(ThreadState *, void *), void *arg)
 
void * joinThread (ThreadState *ts)
 
static InterpreterThreadcreateInterpreterThread (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)
 
ThreadStatecreateThread (ThreadFunc body, void **arg, const char **error)
 
template<typename T>
Tshared_alloc (std::size_t n)
 
template<typename T>
Tshared_alloc0 (std::size_t n)
 
template<typename T>
T shared_free (T *p)
 
template<typename T>
Tshared_alloc (size_t n)
 
template<typename T>
Tshared_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
 
ThreadStatethread_state
 
STATIC_VAR ThreadPoolcurrentThreadPoolRef
 
STATIC_VAR JobcurrentJobRef
 

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

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.

188 {
189 obj->incref();
190}
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.

2660 {
2661 ThreadPool *pool = job->pool;
2662 if (pool) pool->scheduler->lock.lock();
2663 while (arg) {
2664 job->args.push_back(LinTree::to_string(arg));
2665 arg = arg->next;
2666 }
2667 if (pool) pool->scheduler->lock.unlock();
2668}
vector< string > args
Definition shared.cc:1553
ThreadPool * pool
Definition shared.cc:1546
Scheduler * scheduler
Definition shared.cc:1630
void lock()
Definition thread.h:46
void unlock()
Definition thread.h:57
leftv next
Definition subexpr.h:86
std::string to_string(leftv val)
Definition lintree.cc:843

◆ allocate_space()

char * LibThread::allocate_space ( size_t n)

◆ appendArg() [1/2]

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

Definition at line 733 of file shared.cc.

733 {
734 argv.push_back(arg);
735}

◆ appendArg() [2/2]

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

Definition at line 723 of file shared.cc.

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

◆ appendArgCopy()

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

Definition at line 737 of file shared.cc.

737 {
739 val->Copy(arg);
740 argv.push_back(val);
741}
void Copy(leftv e)
Definition subexpr.cc:689
#define omAlloc0Bin(bin)

◆ bindSharedObject()

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

Definition at line 919 of file shared.cc.

919 {
920 if (wrong_num_args("bindSharedObject", arg, 1))
921 return TRUE;
922 if (not_a_uri("bindSharedObject", arg))
923 return TRUE;
924 string uri = str(arg);
926 &global_objects_lock, uri);
927 if (!obj) {
928 WerrorS("bindSharedObject: cannot find object");
929 return TRUE;
930 }
931 result->rtyp = obj->get_type();
932 result->data = new_shared(obj);
933 return FALSE;
934}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
return result
void WerrorS(const char *s)
Definition feFopen.cc:24
char * str(leftv arg)
Definition shared.cc:699
int not_a_uri(const char *name, leftv arg)
Definition shared.cc:682
void * new_shared(SharedObject *obj)
Definition shared.cc:486
Lock global_objects_lock
Definition shared.cc:221
int wrong_num_args(const char *name, leftv arg, int n)
Definition shared.cc:667
SharedObjectTable global_objects
Definition shared.cc:222
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.

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

◆ cancelJob() [2/2]

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

Definition at line 2590 of file shared.cc.

2590 {
2591 Command cmd("cancelJob", result, arg);
2592 cmd.check_argc(1);
2593 cmd.check_arg(0, type_job, "argument must be a job");
2594 cmd.check_init(0, "job not initialized");
2595 if (cmd.ok()) {
2596 Job *job = cmd.shared_arg<Job>(0);
2597 ThreadPool *pool = job->pool;
2598 if (!pool) {
2599 return cmd.abort("job has not yet been started or scheduled");
2600 }
2601 pool->cancelJob(job);
2602 cmd.no_result();
2603 }
2604 return cmd.status();
2605}
int type_job
Definition shared.cc:238

◆ chainTrigger()

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

Definition at line 2752 of file shared.cc.

2752 {
2753 Command cmd("chainTrigger", result, arg);
2754 cmd.check_argc(2);
2755 cmd.check_arg(0, type_trigger, "first argument must be a trigger");
2756 cmd.check_arg(1, type_trigger, type_job,
2757 "second argument must be a trigger or job");
2758 cmd.check_init(0, "trigger not initialized");
2759 cmd.check_init(1, "trigger/job not initialized");
2760 if (cmd.ok()) {
2761 Trigger *trigger = cmd.shared_arg<Trigger>(0);
2762 Job *job = cmd.shared_arg<Job>(1);
2763 if (trigger->pool != job->pool)
2764 return cmd.abort("arguments use different threadpools");
2765 ThreadPool *pool = trigger->pool;
2766 pool->scheduler->lock.lock();
2767 job->triggers.push_back(trigger);
2768 pool->scheduler->lock.unlock();
2769 }
2770 return cmd.status();
2771}
int type_trigger
Definition shared.cc:239

◆ closeThreadPool() [1/2]

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

Definition at line 2308 of file shared.cc.

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

◆ closeThreadPool() [2/2]

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

Definition at line 2324 of file shared.cc.

2324 {
2325 pool->shutdown(wait);
2326}

◆ consChannel()

SharedObject * LibThread::consChannel ( )

Definition at line 711 of file shared.cc.

711 {
712 return new SingularChannel();
713}

◆ consList()

SharedObject * LibThread::consList ( )

Definition at line 707 of file shared.cc.

707 {
708 return new TxList();
709}

◆ consRegion()

SharedObject * LibThread::consRegion ( )

Definition at line 719 of file shared.cc.

719 {
720 return new Region();
721}

◆ consSyncVar()

SharedObject * LibThread::consSyncVar ( )

Definition at line 715 of file shared.cc.

715 {
716 return new SingularSyncVar();
717}

◆ consTable()

SharedObject * LibThread::consTable ( )

Definition at line 703 of file shared.cc.

703 {
704 return new TxTable();
705}

◆ createInterpreterThread()

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

Definition at line 1480 of file shared.cc.

1480 {
1482 if (*error) return NULL;
1483 InterpreterThread *thread = new InterpreterThread(ts);
1484 char buf[10];
1485 sprintf(buf, "%d", ts->index);
1486 string name(buf);
1487 thread->set_name(name);
1488 thread->set_type(type_thread);
1489 return thread;
1490}
#define error(a)
int type_thread
Definition shared.cc:236
static ThreadState * newThread(void *(*thread_func)(ThreadState *, void *), void *arg, const char **error)
Definition shared.cc:1431
void * interpreter_thread(ThreadState *ts, void *arg)
Definition shared.cc:1386
#define NULL
Definition omList.c:12
int status int void * buf
Definition si_signals.h:69
int name
New type name for int.

◆ createJob() [1/3]

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

Definition at line 2444 of file shared.cc.

2444 {
2445 Command cmd("createJob", result, arg);
2446 cmd.check_argc_min(1);
2447 cmd.check_arg(0, STRING_CMD, COMMAND,
2448 "job name must be a string or quote expression");
2449 if (cmd.ok()) {
2450 if (cmd.test_arg(0, STRING_CMD)) {
2451 ProcJob *job = new ProcJob((char *)(cmd.arg(0)));
2452 for (leftv a = arg->next; a != NULL; a = a->next) {
2453 job->args.push_back(LinTree::to_string(a));
2454 }
2455 cmd.set_result(type_job, new_shared(job));
2456 } else {
2457 cmd.check_argc(1);
2458 Job *job = new EvalJob();
2459 job->args.push_back(LinTree::to_string(arg));
2460 cmd.set_result(type_job, new_shared(job));
2461 }
2462 }
2463 return cmd.status();
2464}
@ STRING_CMD
Definition tok.h:187
#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.

2466 {
2467 KernelJob *job = new KernelJob(func);
2468 return job;
2469}

◆ createJob() [3/3]

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

Definition at line 2471 of file shared.cc.

2471 {
2472 RawKernelJob *job = new RawKernelJob(func);
2473 return job;
2474}

◆ createThread() [1/3]

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

Definition at line 1492 of file shared.cc.

1492 {
1493 Command cmd("createThread", result, arg);
1494 cmd.check_argc(0);
1495 const char *error;
1496 if (!have_threads)
1497 cmd.report("thread support not available");
1498 if (!cmd.ok()) return cmd.status();
1500 if (error) {
1501 return cmd.abort(error);
1502 }
1503 cmd.set_result(type_thread, new_shared(thread));
1504 return cmd.status();
1505}
static InterpreterThread * createInterpreterThread(const char **error)
Definition shared.cc:1480
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.

1465 {
1466 return newThread(thread_func, arg, NULL);
1467}

◆ createThreadPool() [1/2]

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

Definition at line 2213 of file shared.cc.

2213 {
2214 ThreadPool *pool = new ThreadPool((int) nthreads);
2216 for (int i = 0; i <nthreads; i++) {
2217 const char *error;
2218 SchedInfo *info = new SchedInfo();
2219 info->scheduler = pool->scheduler;
2220 acquireShared(pool);
2221 info->job = NULL;
2222 info->num = i;
2224 if (!thread) {
2225 return NULL;
2226 }
2227 pool->addThread(thread);
2228 }
2229 return pool;
2230}
int i
Definition cfEzgcd.cc:132
static void * main(ThreadState *ts, void *arg)
Definition shared.cc:1851
void set_type(int type_init)
Definition shared.cc:158
void addThread(ThreadState *thread)
Definition shared.cc:1925
#define info
Definition libparse.cc:1256
void acquireShared(SharedObject *obj)
Definition shared.cc:188

◆ createThreadPool() [2/2]

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

Definition at line 2127 of file shared.cc.

2127 {
2128 long n;
2129 Command cmd("createThreadPool", result, arg);
2130 cmd.check_argc(1, 2);
2131 cmd.check_arg(0, INT_CMD, "first argument must be an integer");
2132 if (cmd.ok()) {
2133 n = (long) cmd.arg(0);
2134 if (n < 0) cmd.report("number of threads must be non-negative");
2135 else if (n >= 256) cmd.report("number of threads too large");
2136 if (!have_threads && n != 0)
2137 cmd.report("in single-threaded mode, number of threads must be zero");
2138 }
2139 if (cmd.ok()) {
2140 ThreadPool *pool = new ThreadPool((int) n);
2142 for (int i = 0; i <n; i++) {
2143 const char *error;
2144 SchedInfo *info = new SchedInfo();
2145 info->scheduler = pool->scheduler;
2146 acquireShared(pool->scheduler);
2147 info->job = NULL;
2148 info->num = i;
2150 if (!thread) {
2151 // TODO: clean up bad pool
2152 return cmd.abort(error);
2153 }
2154 pool->addThread(thread);
2155 }
2156 cmd.set_result(type_threadpool, new_shared(pool));
2157 }
2158 return cmd.status();
2159}

◆ createThreadPoolSet()

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

Definition at line 2161 of file shared.cc.

2161 {
2162 Command cmd("createThreadPoolSet", result, arg);
2163 cmd.check_argc(2);
2164 cmd.check_arg(0, INT_CMD, "first argument must be an integer");
2165 cmd.check_arg(1, LIST_CMD, "second argument must be a list of integers");
2166 lists l;
2167 int n;
2168 if (cmd.ok()) {
2169 l = (lists) (cmd.arg(1));
2170 n = lSize(l)+1;
2171 if (n == 0)
2172 return cmd.abort("second argument must not be empty");
2173 for (int i = 0; i < n; i++) {
2174 if (l->m[i].Typ() != INT_CMD)
2175 return cmd.abort("second argument must be a list of integers");
2176 }
2177 }
2178 lists pools = (lists) omAlloc0Bin(slists_bin);
2179 pools->Init(n);
2180 if (cmd.ok()) {
2181 long s = 0;
2182 for (int i = 0; i < n; i++) {
2183 s += (long) (l->m[i].Data());
2184 }
2185 Scheduler *sched = new Scheduler((int)s);
2186 sched->set_maxconcurrency(cmd.int_arg(0));
2187 for (int i = 0; i < n; i++) {
2188 long m = (long) (l->m[i].Data());
2189 ThreadPool *pool = new ThreadPool(sched, (int) m);
2191 for (int j = 0; j < m; j++) {
2192 const char *error;
2193 SchedInfo *info = new SchedInfo();
2194 info->scheduler = pool->scheduler;
2195 acquireShared(pool->scheduler);
2196 info->job = NULL;
2197 info->num = i;
2199 if (!thread) {
2200 // TODO: clean up bad pool
2201 return cmd.abort(error);
2202 }
2203 pool->addThread(thread);
2204 }
2205 pools->m[i].rtyp = type_threadpool;
2206 pools->m[i].data = new_shared(pool);
2207 }
2208 cmd.set_result(LIST_CMD, pools);
2209 }
2210 return cmd.status();
2211}
int l
Definition cfEzgcd.cc:100
int m
Definition cfEzgcd.cc:128
void set_maxconcurrency(int n)
Definition shared.cc:1677
int rtyp
Definition subexpr.h:91
void * data
Definition subexpr.h:88
sleftv * m
Definition lists.h:46
INLINE_THIS void Init(int l=0)
int j
Definition facHensel.cc:110
VAR omBin slists_bin
Definition lists.cc:23
int lSize(lists L)
Definition lists.cc:25
slists * lists
@ LIST_CMD
Definition tok.h:118

◆ createTrigger()

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

Definition at line 2687 of file shared.cc.

2687 {
2688 Command cmd("createTrigger", result, arg);
2689 cmd.check_argc_min(1);
2690 int has_pool = cmd.test_arg(0, type_threadpool);
2691 ThreadPool *pool;
2692 if (has_pool) {
2693 cmd.check_init(0, "threadpool not initialized");
2694 pool = cmd.shared_arg<ThreadPool>(0);
2695 } else {
2696 pool = currentThreadPoolRef;
2697 if (!pool)
2698 return cmd.abort("no default threadpool");
2699 }
2700 cmd.check_argc(has_pool + 2);
2701 cmd.check_arg(has_pool + 0, STRING_CMD, "trigger subtype must be a string");
2702 const char *kind = (const char *)(cmd.arg(has_pool + 0));
2703 if (0 == strcmp(kind, "proc")) {
2704 cmd.check_arg(has_pool + 1, STRING_CMD, "proc trigger argument must be a string");
2705 } else {
2706 cmd.check_arg(has_pool + 1, INT_CMD, "trigger argument must be an integer");
2707 }
2708 if (cmd.ok()) {
2709 Trigger *trigger;
2710 long n = (long) (cmd.arg(has_pool + 1));
2711 if (n < 0)
2712 return cmd.abort("trigger argument must be a non-negative integer");
2713 if (0 == strcmp(kind, "acc")) {
2714 trigger = new AccTrigger(n);
2715 } else if (0 == strcmp(kind, "count")) {
2716 trigger = new CountTrigger(n);
2717 } else if (0 == strcmp(kind, "set")) {
2718 trigger = new SetTrigger(n);
2719 } else if (0 == strcmp(kind, "proc")) {
2720 trigger = new ProcTrigger((const char *) cmd.arg(has_pool + 1));
2721 } else {
2722 return cmd.abort("unknown trigger subtype");
2723 }
2724 pool->attachJob(trigger);
2725 cmd.set_result(type_trigger, new_shared(trigger));
2726 }
2727 return cmd.status();
2728}
void attachJob(Job *job)
Definition shared.cc:1928
STATIC_VAR ThreadPool * currentThreadPoolRef
Definition shared.cc:1625

◆ currentJob()

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

Definition at line 2893 of file shared.cc.

2893 {
2894 Command cmd("currentJob", result, arg);
2895 cmd.check_argc(0);
2896 Job *job = currentJobRef;
2897 if (job) {
2898 cmd.set_result(type_job, new_shared(job));
2899 } else {
2900 cmd.report("no current job");
2901 }
2902 return cmd.status();
2903}
STATIC_VAR Job * currentJobRef
Definition shared.cc:1626

◆ currentThreadPool()

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

Definition at line 2329 of file shared.cc.

2329 {
2330 Command cmd("currentThreadPool", result, arg);
2331 cmd.check_argc(0);
2333 if (pool) {
2334 cmd.set_result(type_threadpool, new_shared(pool));
2335 } else {
2336 cmd.report("no current threadpool");
2337 }
2338 return cmd.status();
2339}

◆ decode_shared()

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

Definition at line 1276 of file shared.cc.

1276 {
1277 int type = lintree.get_prev<int>();
1278 SharedObject *obj = lintree.get<SharedObject *>();
1280 result->rtyp = type;
1281 result->data = (void *)new_shared(obj);
1282 return result;
1283}

◆ encode_shared()

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

Definition at line 1270 of file shared.cc.

1270 {
1271 SharedObject *obj = *(SharedObject **)(val->Data());
1272 acquireShared(obj);
1273 lintree.put(obj);
1274}
void put(T data)
Definition lintree.h:61
void * Data()
Definition subexpr.cc:1192

◆ executeProc()

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

Definition at line 744 of file shared.cc.

746{
747 leftv procnode = (leftv) omAlloc0Bin(sleftv_bin);
748 procnode->name = omStrDup(procname);
749 procnode->req_packhdl = basePack;
750 int error = procnode->Eval();
751 if (error) {
752 Werror("procedure \"%s\" not found", procname);
753 omFreeBin(procnode, sleftv_bin);
754 return TRUE;
755 }
756 memset(&result, 0, sizeof(result));
757 leftv *tail = &procnode->next;
758 for (unsigned i = 0; i < argv.size(); i++) {
759 *tail = argv[i];
760 tail = &(*tail)->next;
761 }
762 *tail = NULL;
763 error = iiExprArithM(&result, procnode, '(');
764 procnode->CleanUp();
765 omFreeBin(procnode, sleftv_bin);
766 if (error) {
767 Werror("procedure call of \"%s\" failed", procname);
768 return TRUE;
769 }
770 return FALSE;
771}
const char * name
Definition subexpr.h:87
package req_packhdl
Definition subexpr.h:106
int Eval()
Definition subexpr.cc:2000
void CleanUp(ring r=currRing)
Definition subexpr.cc:351
BOOLEAN iiExprArithM(leftv res, leftv a, int op)
Definition iparith.cc:9631
VAR package basePack
Definition ipid.cc:56
#define omStrDup(s)
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.

875 {
876 if (wrong_num_args("findSharedObject", arg, 1))
877 return TRUE;
878 if (not_a_uri("findSharedObject", arg))
879 return TRUE;
880 string uri = str(arg);
882 &global_objects_lock, uri);
883 result->rtyp = INT_CMD;
884 result->data = (char *)(long)(obj != NULL);
885 return FALSE;
886}

◆ findSharedObject() [2/2]

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

Definition at line 266 of file shared.cc.

268{
269 int was_locked = lock->is_locked();
271 if (!was_locked)
272 lock->lock();
273 if (table.count(name)) {
274 result = table[name];
275 }
276 if (!was_locked)
277 lock->unlock();
278 return result;
279}
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.

2514 {
2515 return currentJobRef;
2516}

◆ getCurrentThreadPool()

ThreadPool * LibThread::getCurrentThreadPool ( )

Definition at line 2240 of file shared.cc.

2240 {
2241 return currentThreadPoolRef;
2242}

◆ getJobCancelled() [1/2]

bool LibThread::getJobCancelled ( )

Definition at line 2640 of file shared.cc.

2640 {
2642}
bool getJobCancelled()
Definition shared.cc:2640

◆ getJobCancelled() [2/2]

bool LibThread::getJobCancelled ( Job * job)

Definition at line 2632 of file shared.cc.

2632 {
2633 ThreadPool *pool = job->pool;
2634 if (pool) pool->scheduler->lock.lock();
2635 bool result = job->cancelled;
2636 if (pool) pool->scheduler->lock.unlock();
2637 return result;
2638}

◆ getJobData()

void * LibThread::getJobData ( Job * job)

Definition at line 2652 of file shared.cc.

2652 {
2653 ThreadPool *pool = job->pool;
2654 if (pool) pool->scheduler->lock.lock();
2655 void *result = job->data;
2656 if (pool) pool->scheduler->lock.unlock();
2657 return result;
2658}

◆ getJobName() [1/2]

const char * LibThread::getJobName ( )

◆ getJobName() [2/2]

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

Definition at line 2678 of file shared.cc.

2678 {
2679 // TODO
2680 return "";
2681}

◆ getJobResult()

leftv LibThread::getJobResult ( Job * job)

Definition at line 2670 of file shared.cc.

2670 {
2671 ThreadPool *pool = job->pool;
2672 if (pool) pool->scheduler->lock.lock();
2674 if (pool) pool->scheduler->lock.unlock();
2675 return result;
2676}
string result
Definition shared.cc:1554

◆ getList()

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

Definition at line 1023 of file shared.cc.

1023 {
1024 if (wrong_num_args("getList", arg, 2))
1025 return TRUE;
1026 if (arg->Typ() != type_atomic_list && arg->Typ() != type_shared_list) {
1027 WerrorS("getList: not a valid list (atomic or shared)");
1028 return TRUE;
1029 }
1030 if (arg->next->Typ() != INT_CMD) {
1031 WerrorS("getList: index must be an integer");
1032 return TRUE;
1033 }
1034 TxList *list = *(TxList **) arg->Data();
1035 if (!list) {
1036 WerrorS("getList: list has not been initialized");
1037 return TRUE;
1038 }
1039 long index = (long)(arg->next->Data());
1040 string value;
1041 int success = list->get(index, value);
1042 if (success < 0) {
1043 WerrorS("getList: region not acquired");
1044 return TRUE;
1045 }
1046 if (success == 0) {
1047 WerrorS("getList: no value at position");
1048 return TRUE;
1049 }
1050 leftv tmp = LinTree::from_string(value);
1051 result->rtyp = tmp->Typ();
1052 result->data = tmp->Data();
1053 return FALSE;
1054}
int type_atomic_list
Definition shared.cc:234
int type_shared_list
Definition shared.cc:235
static int index(p_Length length, p_Ord ord)

◆ getSharedName()

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

Definition at line 3051 of file shared.cc.

3051 {
3052 Command cmd("getSharedName", result, arg);
3053 cmd.check_argc(1);
3054 int type = cmd.argtype(0);
3055 cmd.check_init(0, "first argument is not initialized");
3056 if (type != type_job && type != type_trigger && type != type_threadpool) {
3057 cmd.report("first argument must be a job, trigger, or threadpool");
3058 }
3059 if (cmd.ok()) {
3060 SharedObject *obj = cmd.shared_arg<SharedObject>(0);
3061 name_lock.lock();
3062 cmd.set_result(obj->get_name().c_str());
3063 name_lock.unlock();
3064 }
3065 return cmd.status();
3066}
std::string & get_name()
Definition shared.cc:164
Lock name_lock(true)

◆ getTable()

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

Definition at line 936 of file shared.cc.

936 {
937 if (wrong_num_args("getTable", arg, 2))
938 return TRUE;
939 if (arg->Typ() != type_atomic_table && arg->Typ() != type_shared_table) {
940 WerrorS("getTable: not a valid table");
941 return TRUE;
942 }
943 if (arg->next->Typ() != STRING_CMD) {
944 WerrorS("getTable: not a valid table key");
945 return TRUE;
946 }
947 TxTable *table = *(TxTable **) arg->Data();
948 if (!table) {
949 WerrorS("getTable: table has not been initialized");
950 return TRUE;
951 }
952 string key = (char *)(arg->next->Data());
953 string value;
954 int success = table->get(key, value);
955 if (success < 0) {
956 WerrorS("getTable: region not acquired");
957 return TRUE;
958 }
959 if (success == 0) {
960 WerrorS("getTable: key not found");
961 return TRUE;
962 }
963 leftv tmp = LinTree::from_string(value);
964 result->rtyp = tmp->Typ();
965 result->data = tmp->Data();
966 return FALSE;
967}
int get(string &key, string &value)
Definition shared.cc:333
int type_atomic_table
Definition shared.cc:232
int type_shared_table
Definition shared.cc:233

◆ getThreadPoolConcurrency()

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

Definition at line 2276 of file shared.cc.

2276 {
2277 Command cmd("getThreadPoolConcurrency", result, arg);
2278 cmd.check_argc(1);
2279 cmd.check_arg(0, type_threadpool, "argument must be a threadpool");
2280 cmd.check_init(0, "threadpool not initialized");
2281 if (cmd.ok()) {
2282 ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
2283 Scheduler *sched = pool->scheduler;
2284 sched->lock.lock();
2285 cmd.set_result(INT_CMD, sched->get_maxconcurrency());
2286 sched->lock.unlock();
2287 }
2288 return cmd.status();
2289}

◆ getThreadPoolWorkers()

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

Definition at line 2244 of file shared.cc.

2244 {
2245 Command cmd("getThreadPoolWorkers", result, arg);
2246 cmd.check_argc(1);
2247 cmd.check_arg(0, type_threadpool, "argument must be a threadpool");
2248 cmd.check_init(0, "threadpool not initialized");
2249 int r = 0;
2250 if (cmd.ok()) {
2251 ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
2252 Scheduler *sched = pool->scheduler;
2253 sched->lock.lock();
2254 r = sched->threadpool_size(pool);
2255 sched->lock.unlock();
2256 cmd.set_result(INT_CMD, r);
2257 }
2258 return cmd.status();
2259}

◆ installShared()

void LibThread::installShared ( int type)

Definition at line 1297 of file shared.cc.

1297 {
1299}
void ref_shared(LinTree::LinTree &lintree, int by)
Definition shared.cc:1285
void encode_shared(LinTree::LinTree &lintree, leftv val)
Definition shared.cc:1270
leftv decode_shared(LinTree::LinTree &lintree)
Definition shared.cc:1276
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.

969 {
970 if (wrong_num_args("inTable", arg, 2))
971 return TRUE;
972 if (arg->Typ() != type_atomic_table && arg->Typ() != type_shared_table) {
973 WerrorS("inTable: not a valid table");
974 return TRUE;
975 }
976 if (arg->next->Typ() != STRING_CMD) {
977 WerrorS("inTable: not a valid table key");
978 return TRUE;
979 }
980 TxTable *table = *(TxTable **) arg->Data();
981 if (!table) {
982 WerrorS("inTable: table has not been initialized");
983 return TRUE;
984 }
985 string key = (char *)(arg->next->Data());
986 int success = table->check(key);
987 if (success < 0) {
988 WerrorS("inTable: region not acquired");
989 return TRUE;
990 }
991 result->rtyp = INT_CMD;
992 result->data = (char *)(long)(success);
993 return FALSE;
994}
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.

1386 {
1387 ts->lock.lock();
1388 for (;;) {
1389 bool eval = false;
1390 while (ts->to_thread.empty())
1391 ts->to_cond.wait();
1392 /* TODO */
1393 string expr = ts->to_thread.front();
1394 switch (expr[0]) {
1395 case '\0': case 'q':
1396 ts->lock.unlock();
1397 return NULL;
1398 case 'x':
1399 eval = false;
1400 break;
1401 case 'e':
1402 eval = true;
1403 break;
1404 }
1405 ts->to_thread.pop();
1406 expr = ts->to_thread.front();
1407 /* this will implicitly eval commands */
1408 leftv val = LinTree::from_string(expr);
1409 expr = LinTree::to_string(val);
1410 ts->to_thread.pop();
1411 if (eval)
1412 ts->from_thread.push(expr);
1413 ts->from_cond.signal();
1414 }
1415 ts->lock.unlock();
1416 return NULL;
1417}
void signal()
Definition thread.h:97
ConditionVariable to_cond
Definition shared.cc:1341
queue< string > from_thread
Definition shared.cc:1344
ConditionVariable from_cond
Definition shared.cc:1342
queue< string > to_thread
Definition shared.cc:1343
CFList & eval

◆ jobCancelled()

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

Definition at line 2607 of file shared.cc.

2607 {
2608 Job *job;
2609 Command cmd("jobCancelled", result, arg);
2610 cmd.check_argc(0, 1);
2611 if (cmd.nargs() == 1) {
2612 cmd.check_arg(0, type_job, "argument must be a job");
2613 cmd.check_init(0, "job not initialized");
2614 job = cmd.shared_arg<Job>(0);
2615 } else {
2616 job = currentJobRef;
2617 if (!job)
2618 cmd.report("no current job");
2619 }
2620 if (cmd.ok()) {
2621 ThreadPool *pool = job->pool;
2622 if (!pool) {
2623 return cmd.abort("job has not yet been started or scheduled");
2624 }
2625 pool->scheduler->lock.lock();
2626 cmd.set_result((long) job->cancelled);
2627 pool->scheduler->lock.unlock();
2628 }
2629 return cmd.status();
2630}

◆ joinInterpreterThread()

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

Definition at line 1507 of file shared.cc.

1507 {
1508 ThreadState *ts = thread->getThreadState();
1509 if (ts && ts->parent != pthread_self()) {
1510 return false;
1511 }
1512 ts->lock.lock();
1513 string quit("q");
1514 ts->to_thread.push(quit);
1515 ts->to_cond.signal();
1516 ts->lock.unlock();
1517 pthread_join(ts->id, NULL);
1518 thread_lock.lock();
1519 ts->running = false;
1520 ts->active = false;
1521 thread->clearThreadState();
1522 thread_lock.unlock();
1523 return true;
1524}
Lock thread_lock
Definition shared.cc:1359

◆ joinThread() [1/2]

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

Definition at line 1526 of file shared.cc.

1526 {
1527 if (wrong_num_args("joinThread", arg, 1))
1528 return TRUE;
1529 if (arg->Typ() != type_thread) {
1530 WerrorS("joinThread: argument is not a thread");
1531 return TRUE;
1532 }
1533 InterpreterThread *thread = *(InterpreterThread **)arg->Data();
1534 if (!joinInterpreterThread(thread)) {
1535 WerrorS("joinThread: can only be called from parent thread");
1536 return TRUE;
1537 }
1538 return FALSE;
1539}
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.

1469 {
1470 void *result;
1471 pthread_join(ts->id, NULL);
1472 result = ts->result;
1473 thread_lock.lock();
1474 ts->running = false;
1475 ts->active = false;
1476 thread_lock.unlock();
1477 return result;
1478}

◆ lockRegion()

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

Definition at line 1083 of file shared.cc.

1083 {
1084 if (wrong_num_args("lockRegion", arg, 1))
1085 return TRUE;
1086 if (not_a_region("lockRegion", arg))
1087 return TRUE;
1088 Region *region = *(Region **)arg->Data();
1089 if (region->is_locked()) {
1090 WerrorS("lockRegion: region is already locked");
1091 return TRUE;
1092 }
1093 region->lock();
1094 result->rtyp = NONE;
1095 return FALSE;
1096}
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.

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

◆ makeAtomicList()

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

Definition at line 787 of file shared.cc.

787 {
788 if (wrong_num_args("makeAtomicList", arg, 1))
789 return TRUE;
790 if (not_a_uri("makeAtomicList", arg))
791 return TRUE;
792 string uri = str(arg);
795 ((TxList *) obj)->set_region(NULL);
796 result->rtyp = type_atomic_list;
797 result->data = new_shared(obj);
798 return FALSE;
799}
SharedObject * makeSharedObject(SharedObjectTable &table, Lock *lock, int type, string &name, SharedConstructor scons)
Definition shared.cc:244
SharedObject * consList()
Definition shared.cc:707

◆ makeAtomicTable()

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

Definition at line 773 of file shared.cc.

773 {
774 if (wrong_num_args("makeAtomicTable", arg, 1))
775 return TRUE;
776 if (not_a_uri("makeAtomicTable", arg))
777 return TRUE;
778 string uri = str(arg);
781 ((TxTable *) obj)->set_region(NULL);
783 result->data = new_shared(obj);
784 return FALSE;
785}
SharedObject * consTable()
Definition shared.cc:703

◆ makeChannel()

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

Definition at line 836 of file shared.cc.

836 {
837 if (wrong_num_args("makeChannel", arg, 1))
838 return TRUE;
839 if (not_a_uri("makeChannel", arg))
840 return TRUE;
841 string uri = str(arg);
844 result->rtyp = type_channel;
845 result->data = new_shared(obj);
846 return FALSE;
847}
SharedObject * consChannel()
Definition shared.cc:711
int type_channel
Definition shared.cc:230

◆ makeRegion()

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

Definition at line 862 of file shared.cc.

862 {
863 if (wrong_num_args("makeRegion", arg, 1))
864 return TRUE;
865 if (not_a_uri("makeRegion", arg))
866 return TRUE;
867 string uri = str(arg);
870 result->rtyp = type_region;
871 result->data = new_shared(obj);
872 return FALSE;
873}
int type_region
Definition shared.cc:228
SharedObject * consRegion()
Definition shared.cc:719

◆ makeRegionlockType()

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

Definition at line 1316 of file shared.cc.

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

◆ makeSharedList()

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

Definition at line 819 of file shared.cc.

819 {
820 if (wrong_num_args("makeSharedList", arg, 2))
821 return TRUE;
822 if (not_a_region("makeSharedList", arg))
823 return TRUE;
824 if (not_a_uri("makeSharedList", arg->next))
825 return TRUE;
826 Region *region = *(Region **) arg->Data();
827 string s = str(arg->next);
829 region->get_lock(), type_shared_list, s, consList);
830 ((TxList *) obj)->set_region(region);
831 result->rtyp = type_shared_list;
832 result->data = new_shared(obj);
833 return FALSE;
834}
SharedObjectTable objects
Definition shared.cc:204
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.

246{
247 int was_locked = lock->is_locked();
249 if (!was_locked)
250 lock->lock();
251 if (table.count(name)) {
252 result = table[name];
253 if (result->get_type() != type)
254 result = NULL;
255 } else {
256 result = scons();
257 result->set_type(type);
258 result->set_name(name);
259 table.insert(pair<string,SharedObject *>(name, result));
260 }
261 if (!was_locked)
262 lock->unlock();
263 return result;
264}

◆ makeSharedTable()

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

Definition at line 801 of file shared.cc.

801 {
802 if (wrong_num_args("makeSharedTable", arg, 2))
803 return TRUE;
804 if (not_a_region("makeSharedTable", arg))
805 return TRUE;
806 if (not_a_uri("makeSharedTable", arg->next))
807 return TRUE;
808 Region *region = *(Region **) arg->Data();
809 fflush(stdout);
810 string s = str(arg->next);
813 ((TxTable *) obj)->set_region(region);
815 result->data = new_shared(obj);
816 return FALSE;
817}

◆ makeSharedType()

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

Definition at line 1301 of file shared.cc.

1301 {
1302 if (type != 0) return;
1303 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox));
1304 b->blackbox_Init = shared_init;
1305 b->blackbox_destroy = shared_destroy;
1306 b->blackbox_Copy = shared_copy;
1307 b->blackbox_String = shared_string;
1308 b->blackbox_Assign = shared_assign;
1309 b->blackbox_CheckAssign = shared_check_assign;
1310 // b->blackbox_Op2 = shared_op2;
1311 // b->blackbox_Op3 = shared_op3;
1312 type = setBlackboxStuff(b, name);
1313 installShared(type);
1314}
BOOLEAN shared_assign(leftv l, leftv r)
Definition shared.cc:519
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.

849 {
850 if (wrong_num_args("makeSyncVar", arg, 1))
851 return TRUE;
852 if (not_a_uri("makeSyncVar", arg))
853 return TRUE;
854 string uri = str(arg);
857 result->rtyp = type_syncvar;
858 result->data = new_shared(obj);
859 return FALSE;
860}
SharedObject * consSyncVar()
Definition shared.cc:715
int type_syncvar
Definition shared.cc:231

◆ new_shared()

void * LibThread::new_shared ( SharedObject * obj)

Definition at line 486 of file shared.cc.

486 {
487 acquireShared(obj);
488 void *result = omAlloc0(sizeof(SharedObject *));
489 *(SharedObject **)result = obj;
490 return result;
491}

◆ newThread()

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

Definition at line 1431 of file shared.cc.

1432 {
1433 ThreadState *ts = NULL;
1434 if (error) *error = NULL;
1435 thread_lock.lock();
1436 for (int i=0; i<MAX_THREADS; i++) {
1437 if (!thread_state[i].active) {
1438 ts = thread_state + i;
1439 ts->index = i;
1440 ts->parent = pthread_self();
1441 ts->active = true;
1442 ts->running = true;
1443 ts->to_thread = queue<string>();
1444 ts->from_thread = queue<string>();
1445 ts->thread_func = thread_func;
1446 ts->arg = arg;
1447 ts->result = NULL;
1448 if (pthread_create(&ts->id, NULL, thread_main, ts)<0) {
1449 if (error)
1450 *error = "createThread: internal error: failed to create thread";
1451 goto fail;
1452 }
1453 goto exit;
1454 }
1455 }
1456 if (error) *error = "createThread: too many threads";
1457 fail:
1458 ts = NULL;
1459 exit:
1460 thread_lock.unlock();
1461 return ts;
1462}
void *(* thread_func)(ThreadState *, void *)
Definition shared.cc:1336
ThreadState * thread_state
Definition shared.cc:1361
void * thread_main(void *arg)
Definition shared.cc:1380
#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.

690 {
691 if (arg->Typ() != type_region || !arg->Data()) {
692 report("%s: not a region", name);
693 return TRUE;
694 }
695 return FALSE;
696}
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.

682 {
683 if (arg->Typ() != STRING_CMD) {
684 report("%s: not a valid URI", name);
685 return TRUE;
686 }
687 return FALSE;
688}

◆ putList()

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

Definition at line 1056 of file shared.cc.

1056 {
1057 if (wrong_num_args("putList", arg, 3))
1058 return TRUE;
1059 if (arg->Typ() != type_atomic_list && arg->Typ() != type_shared_list) {
1060 WerrorS("putList: not a valid list (shared or atomic)");
1061 return TRUE;
1062 }
1063 if (arg->next->Typ() != INT_CMD) {
1064 WerrorS("putList: index must be an integer");
1065 return TRUE;
1066 }
1067 TxList *list = *(TxList **) arg->Data();
1068 if (!list) {
1069 WerrorS("putList: list has not been initialized");
1070 return TRUE;
1071 }
1072 long index = (long)(arg->next->Data());
1073 string value = LinTree::to_string(arg->next->next);
1074 int success = list->put(index, value);
1075 if (success < 0) {
1076 WerrorS("putList: region not acquired");
1077 return TRUE;
1078 }
1079 result->rtyp = NONE;
1080 return FALSE;
1081}

◆ putTable()

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

Definition at line 996 of file shared.cc.

996 {
997 if (wrong_num_args("putTable", arg, 3))
998 return TRUE;
999 if (arg->Typ() != type_atomic_table && arg->Typ() != type_shared_table) {
1000 WerrorS("putTable: not a valid table");
1001 return TRUE;
1002 }
1003 if (arg->next->Typ() != STRING_CMD) {
1004 WerrorS("putTable: not a valid table key");
1005 return TRUE;
1006 }
1007 TxTable *table = *(TxTable **) arg->Data();
1008 if (!table) {
1009 WerrorS("putTable: table has not been initialized");
1010 return TRUE;
1011 }
1012 string key = (char *)(arg->next->Data());
1013 string value = LinTree::to_string(arg->next->next);
1014 int success = table->put(key, value);
1015 if (success < 0) {
1016 WerrorS("putTable: region not acquired");
1017 return TRUE;
1018 }
1019 result->rtyp = NONE;
1020 return FALSE;
1021}
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.

1233 {
1234 if (wrong_num_args("readSyncVar", arg, 1))
1235 return TRUE;
1236 if (arg->Typ() != type_syncvar) {
1237 WerrorS("readSyncVar: argument is not a syncvar");
1238 return TRUE;
1239 }
1240 SingularSyncVar *syncvar = *(SingularSyncVar **)arg->Data();
1241 if (!syncvar) {
1242 WerrorS("readSyncVar: syncvar has not been initialized");
1243 return TRUE;
1244 }
1245 string item = syncvar->read();
1246 leftv val = LinTree::from_string(item);
1247 result->rtyp = val->Typ();
1248 result->data = val->Data();
1249 return FALSE;
1250}

◆ receiveChannel()

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

Definition at line 1147 of file shared.cc.

1147 {
1148 if (wrong_num_args("receiveChannel", arg, 1))
1149 return TRUE;
1150 if (arg->Typ() != type_channel) {
1151 WerrorS("receiveChannel: argument is not a channel");
1152 return TRUE;
1153 }
1154 SingularChannel *channel = *(SingularChannel **)arg->Data();
1155 if (!channel) {
1156 WerrorS("receiveChannel: channel has not been initialized");
1157 return TRUE;
1158 }
1159 string item = channel->receive();
1160 leftv val = LinTree::from_string(item);
1161 result->rtyp = val->Typ();
1162 result->data = val->Data();
1163 return FALSE;
1164}

◆ ref_shared()

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

Definition at line 1285 of file shared.cc.

1285 {
1286 SharedObject *obj = lintree.get<SharedObject *>();
1287 while (by > 0) {
1288 obj->incref();
1289 by--;
1290 }
1291 while (by < 0) {
1292 obj->decref();
1293 by++;
1294 }
1295}

◆ regionLock()

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

Definition at line 1098 of file shared.cc.

1098 {
1099 if (wrong_num_args("lockRegion", arg, 1))
1100 return TRUE;
1101 if (not_a_region("lockRegion", arg))
1102 return TRUE;
1103 Region *region = *(Region **)arg->Data();
1104 if (region->is_locked()) {
1105 WerrorS("lockRegion: region is already locked");
1106 return TRUE;
1107 }
1108 region->lock();
1109 result->rtyp = type_regionlock;
1110 result->data = new_shared(region);
1111 return FALSE;
1112}
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.

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

◆ releaseShared()

void LibThread::releaseShared ( SharedObject * obj)

Definition at line 192 of file shared.cc.

192 {
193 if (obj->decref() == 0) {
194 // delete obj;
195 }
196}

◆ report()

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

Definition at line 661 of file shared.cc.

661 {
662 char buf[80];
663 sprintf(buf, fmt, name);
664 WerrorS(buf);
665}

◆ retain() [1/2]

void LibThread::retain ( Job * job)

◆ retain() [2/2]

void LibThread::retain ( ThreadPool * pool)

Definition at line 2236 of file shared.cc.

2236 {
2237 acquireShared(pool);
2238}

◆ rlock_assign()

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

Definition at line 544 of file shared.cc.

544 {
545 if (r->Typ() == l->Typ()) {
546 if (l->rtyp == IDHDL) {
547 omFree(IDDATA((idhdl)l->data));
548 IDDATA((idhdl)l->data) = (char*)shared_copy(NULL,r->Data());
549 } else {
550 leftv ll=l->LData();
551 if (ll==NULL)
552 {
553 return TRUE; // out of array bounds or similiar
554 }
555 rlock_destroy(NULL, ll->data);
556 omFree(ll->data);
557 ll->data = shared_copy(NULL,r->Data());
558 }
559 } else {
560 Werror("assign %s(%d) = %s(%d)",
561 Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ());
562 return TRUE;
563 }
564 return FALSE;
565}
const char * Tok2Cmdname(int tok)
Definition gentable.cc:137
#define IDDATA(a)
Definition ipid.h:126
#define omFree(addr)
idrec * idhdl
Definition ring.h:22
#define IDHDL
Definition tok.h:31

◆ rlock_destroy()

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

Definition at line 501 of file shared.cc.

501 {
502 SharedObject *obj = *(SharedObject **)d;
503 ((Region *) obj)->unlock();
504 if (obj) {
506 *(SharedObject **)d = NULL;
507 }
508}

◆ rlock_string()

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

Definition at line 652 of file shared.cc.

652 {
653 char buf[80];
654 SharedObject *obj = *(SharedObject **)d;
655 if (!obj)
656 return omStrDup("<uninitialized region lock>");
657 sprintf(buf, "<region lock \"%.40s\">", obj->get_name().c_str());
658 return omStrDup(buf);
659}

◆ scheduleJob()

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

Definition at line 2789 of file shared.cc.

2789 {
2790 vector<Job *> jobs;
2791 vector<Job *> deps;
2792 Command cmd("scheduleJob", result, arg);
2793 cmd.check_argc_min(1);
2794 int has_pool = cmd.test_arg(0, type_threadpool);
2795 if (has_pool) {
2796 cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
2797 cmd.check_init(0, "threadpool not initialized");
2798 }
2799 cmd.check_argc_min(has_pool+1);
2800 int has_prio = cmd.test_arg(has_pool, INT_CMD);
2801 ThreadPool *pool;
2802 if (has_pool)
2803 pool = cmd.shared_arg<ThreadPool>(0);
2804 else {
2806 return cmd.abort("no current threadpool defined");
2807 pool = currentThreadPoolRef;
2808 }
2809 long prio = has_prio ? (long) cmd.arg(has_pool) : 0L;
2810 int first_arg = has_pool + has_prio;
2811 if (cmd.test_arg(first_arg, type_job)) {
2812 jobs.push_back(*(Job **)(cmd.arg(first_arg)));
2813 } else if (cmd.test_arg(first_arg, STRING_CMD)) {
2814 jobs.push_back(new ProcJob((char *)(cmd.arg(first_arg))));
2815 } else if (cmd.test_arg(first_arg, LIST_CMD)) {
2816 lists l = (lists) (cmd.arg(first_arg));
2817 int n = lSize(l);
2818 for (int i = 0; i < n; i++) {
2819 if (l->m[i].Typ() != type_job)
2820 return cmd.abort("job argument must be a job, string, or list of jobs");
2821 }
2822 for (int i = 0; i < n; i++) {
2823 Job *job = *(Job **) (l->m[i].Data());
2824 if (!job)
2825 return cmd.abort("job not initialized");
2826 jobs.push_back(job);
2827 }
2828 } else {
2829 return cmd.abort("job argument must be a job, string, or list of jobs");
2830 }
2831 bool error = false;
2832 leftv a = arg->next;
2833 if (has_pool) a = a->next;
2834 if (has_prio) a = a->next;
2835 for (; !error && a; a = a->next) {
2836 if (a->Typ() == type_job || a->Typ() == type_trigger) {
2837 deps.push_back(*(Job **)(a->Data()));
2838 } else if (a->Typ() == LIST_CMD) {
2839 lists l = (lists) a->Data();
2840 int n = lSize(l);
2841 for (int i = 0; i < n; i++) {
2842 if (l->m[i].Typ() == type_job || l->m[i].Typ() == type_trigger) {
2843 deps.push_back(*(Job **)(l->m[i].Data()));
2844 } else {
2845 error = true;
2846 break;
2847 }
2848 }
2849 }
2850 }
2851 if (error) {
2852 return cmd.abort("illegal dependency");
2853 }
2854 for (unsigned i = 0; i < jobs.size(); i++) {
2855 Job *job = jobs[i];
2856 if (job->pool) {
2857 return cmd.abort("job has already been scheduled");
2858 }
2859 job->prio = prio;
2860 }
2861 for (unsigned i = 0; i < deps.size(); i++) {
2862 Job *job = deps[i];
2863 if (!job->pool) {
2864 return cmd.abort("dependency has not yet been scheduled");
2865 }
2866 if (job->pool != pool) {
2867 return cmd.abort("dependency has been scheduled on a different threadpool");
2868 }
2869 }
2870 pool->scheduler->lock.lock();
2871 bool cancelled = false;
2872 for (unsigned i = 0; i < jobs.size(); i++) {
2873 jobs[i]->addDep(deps);
2874 }
2875 for (unsigned i = 0; i < deps.size(); i++) {
2876 deps[i]->addNotify(jobs);
2877 cancelled |= deps[i]->cancelled;
2878 }
2879 for (unsigned i = 0; i < jobs.size(); i++) {
2880 if (cancelled) {
2881 jobs[i]->pool = pool;
2882 pool->cancelJob(jobs[i]);
2883 }
2884 else
2885 pool->attachJob(jobs[i]);
2886 }
2887 pool->scheduler->lock.unlock();
2888 if (jobs.size() > 0)
2889 cmd.set_result(type_job, new_shared(jobs[0]));
2890 return cmd.status();
2891}

◆ sendChannel()

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

Definition at line 1130 of file shared.cc.

1130 {
1131 if (wrong_num_args("sendChannel", arg, 2))
1132 return TRUE;
1133 if (arg->Typ() != type_channel) {
1134 WerrorS("sendChannel: argument is not a channel");
1135 return TRUE;
1136 }
1137 SingularChannel *channel = *(SingularChannel **)arg->Data();
1138 if (!channel) {
1139 WerrorS("sendChannel: channel has not been initialized");
1140 return TRUE;
1141 }
1142 channel->send(LinTree::to_string(arg->next));
1143 result->rtyp = NONE;
1144 return FALSE;
1145}
void send(string item)
Definition shared.cc:400

◆ setCurrentThreadPool()

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

Definition at line 2341 of file shared.cc.

2341 {
2342 Command cmd("setCurrentThreadPool", result, arg);
2343 cmd.check_argc(1);
2344 cmd.check_init(0, "threadpool not initialized");
2345 if (cmd.ok()) {
2346 ThreadPool *pool = *(ThreadPool **)(cmd.arg(0));
2347 acquireShared(pool);
2350 currentThreadPoolRef = pool;
2351 }
2352 return cmd.status();
2353}

◆ setJobData()

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

Definition at line 2644 of file shared.cc.

2644 {
2645 ThreadPool *pool = job->pool;
2646 if (pool) pool->scheduler->lock.lock();
2647 job->data = data;
2648 if (pool) pool->scheduler->lock.unlock();
2649}

◆ 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.

2683 {
2684 // TODO
2685}

◆ setOption()

void LibThread::setOption ( int ch)

Definition at line 1363 of file shared.cc.

1363 {
1364 int index = feGetOptIndex(ch);
1365 feSetOptValue((feOptIndex) index, (int) 1);
1366}
feOptIndex
Definition feOptGen.h:15
feOptIndex feGetOptIndex(const char *name)
Definition feOpt.cc:104
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.

3033 {
3034 Command cmd("setSharedName", result, arg);
3035 cmd.check_argc(2);
3036 int type = cmd.argtype(0);
3037 cmd.check_init(0, "first argument is not initialized");
3038 if (type != type_job && type != type_trigger && type != type_threadpool) {
3039 cmd.report("first argument must be a job, trigger, or threadpool");
3040 }
3041 cmd.check_arg(1, STRING_CMD, "second argument must be a string");
3042 if (cmd.ok()) {
3043 SharedObject *obj = cmd.shared_arg<SharedObject>(0);
3044 name_lock.lock();
3045 obj->set_name((char *) cmd.arg(1));
3046 name_lock.unlock();
3047 }
3048 return cmd.status();
3049}
void set_name(std::string &name_init)
Definition shared.cc:160

◆ setThreadPoolConcurrency()

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

Definition at line 2291 of file shared.cc.

2291 {
2292 Command cmd("setThreadPoolWorkers", result, arg);
2293 cmd.check_argc(2);
2294 cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
2295 cmd.check_arg(1, INT_CMD, "second argument must be an integer");
2296 cmd.check_init(0, "threadpool not initialized");
2297 if (cmd.ok()) {
2298 ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
2299 Scheduler *sched = pool->scheduler;
2300 sched->lock.lock();
2301 sched->set_maxconcurrency(cmd.int_arg(1));
2302 sched->lock.unlock();
2303 cmd.no_result();
2304 }
2305 return cmd.status();
2306}

◆ setThreadPoolWorkers()

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

Definition at line 2261 of file shared.cc.

2261 {
2262 Command cmd("setThreadPoolWorkers", result, arg);
2263 cmd.check_argc(2);
2264 cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
2265 cmd.check_arg(1, INT_CMD, "second argument must be an integer");
2266 cmd.check_init(0, "threadpool not initialized");
2267 if (cmd.ok()) {
2268 ThreadPool *pool = cmd.shared_arg<ThreadPool>(0);
2269 Scheduler *sched = pool->scheduler;
2270 // TODO: count/add threads
2271 cmd.no_result();
2272 }
2273 return cmd.status();
2274}

◆ shared_alloc() [1/2]

template<typename T>
T * LibThread::shared_alloc ( size_t n)

Definition at line 42 of file thread.cc.

42 {
43 T *p = (T *) malloc(n * sizeof(T));
44 return p;
45 }
int p
Definition cfModGcd.cc:4086
STATIC_VAR jList * T
Definition janet.cc:30
#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.

47 {
48 T *p = (T *) calloc(n, sizeof(T));
49 return p;
50 }
#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.

519 {
520 if (r->Typ() == l->Typ()) {
521 if (l->rtyp == IDHDL) {
522 omFree(IDDATA((idhdl)l->data));
523 IDDATA((idhdl)l->data) = (char*)shared_copy(NULL,r->Data());
524 } else {
525 leftv ll=l->LData();
526 if (ll==NULL)
527 {
528 return TRUE; // out of array bounds or similiar
529 }
530 if (ll->data) {
532 omFree(ll->data);
533 }
534 ll->data = shared_copy(NULL,r->Data());
535 }
536 } else {
537 Werror("assign %s(%d) = %s(%d)",
538 Tok2Cmdname(l->Typ()),l->Typ(),Tok2Cmdname(r->Typ()),r->Typ());
539 return TRUE;
540 }
541 return FALSE;
542}

◆ shared_check_assign()

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

Definition at line 568 of file shared.cc.

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

◆ shared_copy()

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

Definition at line 510 of file shared.cc.

510 {
511 SharedObject *obj = *(SharedObject **)d;
512 void *result = shared_init(b);
513 *(SharedObject **)result = obj;
514 if (obj)
515 acquireShared(obj);
516 return result;
517}

◆ shared_destroy()

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

Definition at line 493 of file shared.cc.

493 {
494 SharedObject *obj = *(SharedObject **)d;
495 if (obj) {
497 *(SharedObject **)d = NULL;
498 }
499}

◆ shared_free() [1/2]

template<typename T>
T LibThread::shared_free ( T * p)

Definition at line 52 of file thread.cc.

52 {
53 free(p);
54 }
#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.

52 {
53 free(p);
54 }

◆ shared_init()

void * LibThread::shared_init ( blackbox * b)

Definition at line 482 of file shared.cc.

482 {
483 return omAlloc0(sizeof(SharedObject *));
484}

◆ shared_op2()

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

Definition at line 580 of file shared.cc.

580 {
581 SharedObject *obj = *(SharedObject **)a1->Data();
582 return obj->op2(op, res, a1, a2);
583}
virtual BOOLEAN op2(int op, leftv res, leftv a1, leftv a2)
Definition shared.cc:180
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.

585 {
586 SharedObject *obj = *(SharedObject **)a1->Data();
587 return obj->op3(op, res, a1, a2, a3);
588}
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.

590 {
591 char buf[80];
592 SharedObject *obj = *(SharedObject **)d;
593 if (!obj)
594 return omStrDup("<uninitialized shared object>");
595 int type = obj->get_type();
596 string &name = obj->get_name();
597 const char *type_name = "unknown";
598 if (type == type_channel)
599 type_name = "channel";
600 else if (type == type_atomic_table)
601 type_name = "atomic_table";
602 else if (type == type_shared_table)
603 type_name = "shared_table";
604 else if (type == type_atomic_list)
605 type_name = "atomic_list";
606 else if (type == type_shared_list)
607 type_name = "shared_list";
608 else if (type == type_syncvar)
609 type_name = "syncvar";
610 else if (type == type_region)
611 type_name = "region";
612 else if (type == type_regionlock)
613 type_name = "regionlock";
614 else if (type == type_thread) {
615 sprintf(buf, "<thread #%s>", name.c_str());
616 return omStrDup(buf);
617 }
618 else if (type == type_threadpool) {
619 if (name.size() > 0) {
620 name_lock.lock();
621 sprintf(buf, "<threadpool \"%.40s\"@%p>", name.c_str(), obj);
622 name_lock.unlock();
623 } else
624 sprintf(buf, "<threadpool @%p>", obj);
625 return omStrDup(buf);
626 }
627 else if (type == type_job) {
628 if (name.size() > 0) {
629 name_lock.lock();
630 sprintf(buf, "<job \"%.40s\"@%p>", name.c_str(), obj);
631 name_lock.unlock();
632 } else
633 sprintf(buf, "<job @%p>", obj);
634 return omStrDup(buf);
635 }
636 else if (type == type_trigger) {
637 if (name.size() > 0) {
638 name_lock.lock();
639 sprintf(buf, "<trigger \"%.40s\"@%p>", name.c_str(), obj);
640 name_lock.unlock();
641 } else
642 sprintf(buf, "<trigger @%p>", obj);
643 return omStrDup(buf);
644 } else {
645 sprintf(buf, "<unknown type %d>", type);
646 return omStrDup(buf);
647 }
648 sprintf(buf, "<%s \"%.40s\">", type_name, name.c_str());
649 return omStrDup(buf);
650}

◆ startJob() [1/3]

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

Definition at line 2518 of file shared.cc.

2518 {
2519 Command cmd("startJob", result, arg);
2520 cmd.check_argc_min(1);
2521 int has_pool = cmd.test_arg(0, type_threadpool);
2522 cmd.check_argc_min(1+has_pool);
2523 if (has_pool)
2524 cmd.check_init(0, "threadpool not initialized");
2525 int has_prio = cmd.test_arg(has_pool, INT_CMD);
2526 long prio = has_prio ? (long) cmd.arg(has_pool) : 0L;
2527 int first_arg = has_pool + has_prio;
2528 cmd.check_arg(first_arg, type_job, STRING_CMD,
2529 "job argument must be a job or string");
2530 if (cmd.ok() && cmd.argtype(first_arg) == type_job)
2531 cmd.check_init(first_arg, "job not initialized");
2532 if (!cmd.ok()) return cmd.status();
2533 ThreadPool *pool;
2534 if (has_pool)
2535 pool = cmd.shared_arg<ThreadPool>(0);
2536 else {
2538 return cmd.abort("no current threadpool defined");
2539 pool = currentThreadPoolRef;
2540 }
2541 Job *job;
2542 if (cmd.argtype(first_arg) == type_job)
2543 job = *(Job **)(cmd.arg(first_arg));
2544 else
2545 job = new ProcJob((char *)(cmd.arg(first_arg)));
2546 leftv a = arg->next;
2547 if (has_pool) a = a->next;
2548 if (has_prio) a = a->next;
2549 for (; a != NULL; a = a->next) {
2550 job->args.push_back(LinTree::to_string(a));
2551 }
2552 if (job->pool)
2553 return cmd.abort("job has already been scheduled");
2554 job->prio = prio;
2555 pool->attachJob(job);
2556 cmd.set_result(type_job, new_shared(job));
2557 return cmd.status();
2558}

◆ startJob() [2/3]

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

Definition at line 2486 of file shared.cc.

2486 {
2487 return startJob(pool, job, NULL);
2488}
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.

2476 {
2477 if (job->pool) return NULL;
2478 while (arg) {
2479 job->args.push_back(LinTree::to_string(arg));
2480 arg = arg->next;
2481 }
2482 pool->attachJob(job);
2483 return job;
2484}

◆ statChannel()

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

Definition at line 1166 of file shared.cc.

1166 {
1167 if (wrong_num_args("statChannel", arg, 1))
1168 return TRUE;
1169 if (arg->Typ() != type_channel) {
1170 WerrorS("statChannel: argument is not a channel");
1171 return TRUE;
1172 }
1173 SingularChannel *channel = *(SingularChannel **)arg->Data();
1174 if (!channel) {
1175 WerrorS("receiveChannel: channel has not been initialized");
1176 return TRUE;
1177 }
1178 long n = channel->count();
1179 result->rtyp = INT_CMD;
1180 result->data = (char *)n;
1181 return FALSE;
1182}

◆ statSyncVar()

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

Definition at line 1252 of file shared.cc.

1252 {
1253 if (wrong_num_args("statSyncVar", arg, 1))
1254 return TRUE;
1255 if (arg->Typ() != type_syncvar) {
1256 WerrorS("statSyncVar: argument is not a syncvar");
1257 return TRUE;
1258 }
1259 SingularSyncVar *syncvar = *(SingularSyncVar **)arg->Data();
1260 if (!syncvar) {
1261 WerrorS("statSyncVar: syncvar has not been initialized");
1262 return TRUE;
1263 }
1264 int init = syncvar->check();
1265 result->rtyp = INT_CMD;
1266 result->data = (char *)(long) init;
1267 return FALSE;
1268}
void init()
Definition lintree.cc:864

◆ str()

char * LibThread::str ( leftv arg)

Definition at line 699 of file shared.cc.

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

◆ testTrigger()

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

Definition at line 2773 of file shared.cc.

2773 {
2774 Command cmd("testTrigger", result, arg);
2775 cmd.check_argc(1);
2776 cmd.check_arg(0, type_trigger, "argument must be a trigger");
2777 cmd.check_init(0, "trigger not initialized");
2778 if (cmd.ok()) {
2779 Trigger *trigger = cmd.shared_arg<Trigger>(0);
2780 ThreadPool *pool = trigger->pool;
2781 pool->scheduler->lock.lock();
2782 cmd.set_result((long)trigger->ready());
2783 pool->scheduler->lock.unlock();
2784 }
2785 return cmd.status();
2786}
virtual bool ready()
Definition shared.cc:1600

◆ thread_init()

void LibThread::thread_init ( )

Definition at line 1368 of file shared.cc.

1368 {
1369 master_lock.lock();
1371 master_lock.unlock();
1372#ifdef ENABLE_THREADS
1374 siInit(global_argv0);
1375#endif
1376 setOption('q');
1377 // setOption('b');
1378}
void siInit(char *)
Definition misc_ip.cc:1361
long thread_counter
Definition shared.cc:226
void setOption(int ch)
Definition shared.cc:1363
Lock master_lock(true)
void pSingular_initialize_thread()

◆ thread_main()

void * LibThread::thread_main ( void * arg)

Definition at line 1380 of file shared.cc.

1380 {
1381 ThreadState *ts = (ThreadState *)arg;
1382 thread_init();
1383 return ts->thread_func(ts, ts->arg);
1384}
void thread_init()
Definition shared.cc:1368

◆ threadEval()

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

Definition at line 2922 of file shared.cc.

2922 {
2923 if (wrong_num_args("threadEval", arg, 2))
2924 return TRUE;
2925 if (arg->Typ() != type_thread) {
2926 WerrorS("threadEval: argument is not a thread");
2927 return TRUE;
2928 }
2929 InterpreterThread *thread = *(InterpreterThread **)arg->Data();
2930 string expr = LinTree::to_string(arg->next);
2931 ThreadState *ts = thread->getThreadState();
2932 if (ts && ts->parent != pthread_self()) {
2933 WerrorS("threadEval: can only be called from parent thread");
2934 return TRUE;
2935 }
2936 if (ts) ts->lock.lock();
2937 if (!ts || !ts->running || !ts->active) {
2938 WerrorS("threadEval: thread is no longer running");
2939 if (ts) ts->lock.unlock();
2940 return TRUE;
2941 }
2942 ts->to_thread.push("e");
2943 ts->to_thread.push(expr);
2944 ts->to_cond.signal();
2945 ts->lock.unlock();
2946 result->rtyp = NONE;
2947 return FALSE;
2948}

◆ threadExec()

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

Definition at line 2950 of file shared.cc.

2950 {
2951 if (wrong_num_args("threadExec", arg, 2))
2952 return TRUE;
2953 if (arg->Typ() != type_thread) {
2954 WerrorS("threadExec: argument is not a thread");
2955 return TRUE;
2956 }
2957 InterpreterThread *thread = *(InterpreterThread **)arg->Data();
2958 string expr = LinTree::to_string(arg->next);
2959 ThreadState *ts = thread->getThreadState();
2960 if (ts && ts->parent != pthread_self()) {
2961 WerrorS("threadExec: can only be called from parent thread");
2962 return TRUE;
2963 }
2964 if (ts) ts->lock.lock();
2965 if (!ts || !ts->running || !ts->active) {
2966 WerrorS("threadExec: thread is no longer running");
2967 if (ts) ts->lock.unlock();
2968 return TRUE;
2969 }
2970 ts->to_thread.push("x");
2971 ts->to_thread.push(expr);
2972 ts->to_cond.signal();
2973 ts->lock.unlock();
2974 result->rtyp = NONE;
2975 return FALSE;
2976}

◆ threadID()

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

Definition at line 2906 of file shared.cc.

2906 {
2907 if (wrong_num_args("threadID", arg, 0))
2908 return TRUE;
2909 result->rtyp = INT_CMD;
2910 result->data = (char *)thread_id;
2911 return FALSE;
2912}

◆ threadPoolExec()

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

Definition at line 2978 of file shared.cc.

2978 {
2979 Command cmd("threadPoolExec", result, arg);
2980 ThreadPool *pool;
2981 cmd.check_argc(1, 2);
2982 int has_pool = cmd.nargs() == 2;
2983 if (has_pool) {
2984 cmd.check_arg(0, type_threadpool, "first argument must be a threadpool");
2985 cmd.check_init(0, "threadpool not initialized");
2986 pool = cmd.shared_arg<ThreadPool>(0);
2987 } else {
2988 pool = currentThreadPoolRef;
2989 if (!pool)
2990 return cmd.abort("no current threadpool");
2991 }
2992 if (cmd.ok()) {
2993 string expr = LinTree::to_string(has_pool ? arg->next : arg);
2994 Job* job = new ExecJob();
2995 job->args.push_back(expr);
2996 job->pool = pool;
2997 pool->broadcastJob(job);
2998 }
2999 return cmd.status();
3000}
void broadcastJob(Job *job)
Definition shared.cc:1937

◆ threadResult()

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

Definition at line 3002 of file shared.cc.

3002 {
3003 if (wrong_num_args("threadResult", arg, 1))
3004 return TRUE;
3005 if (arg->Typ() != type_thread) {
3006 WerrorS("threadResult: argument is not a thread");
3007 return TRUE;
3008 }
3009 InterpreterThread *thread = *(InterpreterThread **)arg->Data();
3010 ThreadState *ts = thread->getThreadState();
3011 if (ts && ts->parent != pthread_self()) {
3012 WerrorS("threadResult: can only be called from parent thread");
3013 return TRUE;
3014 }
3015 if (ts) ts->lock.lock();
3016 if (!ts || !ts->running || !ts->active) {
3017 WerrorS("threadResult: thread is no longer running");
3018 if (ts) ts->lock.unlock();
3019 return TRUE;
3020 }
3021 while (ts->from_thread.empty()) {
3022 ts->from_cond.wait();
3023 }
3024 string expr = ts->from_thread.front();
3025 ts->from_thread.pop();
3026 ts->lock.unlock();
3027 leftv val = LinTree::from_string(expr);
3028 result->rtyp = val->Typ();
3029 result->data = val->Data();
3030 return FALSE;
3031}

◆ typeSharedObject()

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

Definition at line 888 of file shared.cc.

888 {
889 if (wrong_num_args("findSharedObject", arg, 1))
890 return TRUE;
891 if (not_a_uri("findSharedObject", arg))
892 return TRUE;
893 string uri = str(arg);
895 &global_objects_lock, uri);
896 int type = obj ? obj->get_type() : -1;
897 const char *type_name = "undefined";
898 if (type == type_channel)
899 type_name = "channel";
900 else if (type == type_atomic_table)
901 type_name = "atomic_table";
902 else if (type == type_shared_table)
903 type_name = "shared_table";
904 else if (type == type_atomic_list)
905 type_name = "atomic_list";
906 else if (type == type_shared_list)
907 type_name = "shared_list";
908 else if (type == type_syncvar)
909 type_name = "syncvar";
910 else if (type == type_region)
911 type_name = "region";
912 else if (type == type_regionlock)
913 type_name = "regionlock";
914 result->rtyp = STRING_CMD;
915 result->data = (char *)(omStrDup(type_name));
916 return FALSE;
917}

◆ unlockRegion()

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

Definition at line 1115 of file shared.cc.

1115 {
1116 if (wrong_num_args("unlockRegion", arg, 1))
1117 return TRUE;
1118 if (not_a_region("unlockRegion", arg))
1119 return TRUE;
1120 Region *region = *(Region **)arg->Data();
1121 if (!region->is_locked()) {
1122 WerrorS("unlockRegion: region is not locked");
1123 return TRUE;
1124 }
1125 region->unlock();
1126 result->rtyp = NONE;
1127 return FALSE;
1128}

◆ updateSyncVar()

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

Definition at line 1204 of file shared.cc.

1204 {
1205 Command cmd("updateSyncVar", result, arg);
1206 cmd.check_argc_min(2);
1207 cmd.check_arg(0, type_syncvar, "first argument must be a syncvar");
1208 cmd.check_init(0, "syncvar has not been initialized");
1209 cmd.check_arg(1, STRING_CMD, "second argument must be a string");
1210 if (cmd.ok()) {
1211 SingularSyncVar *syncvar = cmd.shared_arg<SingularSyncVar>(0);
1212 char *procname = (char *) cmd.arg(1);
1213 arg = arg->next->next;
1214 syncvar->acquire();
1215 syncvar->wait_init();
1216 vector<leftv> argv;
1217 appendArg(argv, syncvar->get());
1218 while (arg) {
1219 appendArgCopy(argv, arg);
1220 arg = arg->next;
1221 }
1222 int error = executeProc(*result, procname, argv);
1223 if (!error) {
1224 syncvar->update(result);
1225 }
1226 syncvar->release();
1227 return error;
1228 }
1229 return cmd.status();
1230}
void update(leftv val)
Definition shared.cc:449
static void appendArgCopy(vector< leftv > &argv, leftv arg)
Definition shared.cc:737
static void appendArg(vector< leftv > &argv, string &s)
Definition shared.cc:723
static BOOLEAN executeProc(sleftv &result, const char *procname, const vector< leftv > &argv)
Definition shared.cc:744

◆ updateTrigger()

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

Definition at line 2730 of file shared.cc.

2730 {
2731 Command cmd("updateTrigger", result, arg);
2732 cmd.check_argc_min(1);
2733 cmd.check_arg(0, type_trigger, "first argument must be a trigger");
2734 cmd.check_init(0, "trigger not initialized");
2735 if (cmd.ok()) {
2736 Trigger *trigger = cmd.shared_arg<Trigger>(0);
2737 trigger->pool->scheduler->lock.lock();
2738 if (!trigger->accept(arg->next))
2739 cmd.report("incompatible argument type(s) for this trigger");
2740 else {
2741 trigger->activate(arg->next);
2742 if (trigger->ready()) {
2743 trigger->run();
2744 Scheduler::notifyDeps(trigger->pool->scheduler, trigger);
2745 }
2746 }
2747 trigger->pool->scheduler->lock.unlock();
2748 }
2749 return cmd.status();
2750}
static void notifyDeps(Scheduler *scheduler, Job *job)
Definition shared.cc:1824
virtual void activate(leftv arg)=0
virtual bool accept(leftv arg)=0

◆ waitJob() [1/2]

void LibThread::waitJob ( Job * job)

Definition at line 2585 of file shared.cc.

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

◆ waitJob() [2/2]

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

Definition at line 2560 of file shared.cc.

2560 {
2561 Command cmd("waitJob", result, arg);
2562 cmd.check_argc(1);
2563 cmd.check_arg(0, type_job, "argument must be a job");
2564 cmd.check_init(0, "job not initialized");
2565 if (cmd.ok()) {
2566 Job *job = *(Job **)(cmd.arg(0));
2567 ThreadPool *pool = job->pool;
2568 if (!pool) {
2569 return cmd.abort("job has not yet been started or scheduled");
2570 }
2571 pool->waitJob(job);
2572 if (job->cancelled) {
2573 return cmd.abort("job has been cancelled");
2574 }
2575 if (job->result.size() == 0)
2576 cmd.no_result();
2577 else {
2579 cmd.set_result(res->Typ(), res->Data());
2580 }
2581 }
2582 return cmd.status();
2583}

◆ writeSyncVar()

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

Definition at line 1184 of file shared.cc.

1184 {
1185 if (wrong_num_args("writeSyncVar", arg, 2))
1186 return TRUE;
1187 if (arg->Typ() != type_syncvar) {
1188 WerrorS("writeSyncVar: argument is not a syncvar");
1189 return TRUE;
1190 }
1191 SingularSyncVar *syncvar = *(SingularSyncVar **)arg->Data();
1192 if (!syncvar) {
1193 WerrorS("writeSyncVar: syncvar has not been initialized");
1194 return TRUE;
1195 }
1196 if (!syncvar->write(LinTree::to_string(arg->next))) {
1197 WerrorS("writeSyncVar: variable already has a value");
1198 return TRUE;
1199 }
1200 result->rtyp = NONE;
1201 return FALSE;
1202}
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.

667 {
668 for (int i=1; i<=n; i++) {
669 if (!arg) {
670 report("%s: too few arguments", name);
671 return TRUE;
672 }
673 arg = arg->next;
674 }
675 if (arg) {
676 report("%s: too many arguments", name);
677 return TRUE;
678 }
679 return FALSE;
680}

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.