MCPcopy Create free account
hub / github.com/Singular/Singular / threadExec

Function threadExec

Singular/dyn_modules/systhreads/shared.cc:2950–2976  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2948}
2949
2950BOOLEAN threadExec(leftv result, leftv arg) {
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}
2977
2978BOOLEAN threadPoolExec(leftv result, leftv arg) {
2979 Command cmd("threadPoolExec", result, arg);

Callers

nothing calls this directly

Calls 10

wrong_num_argsFunction · 0.85
WerrorSFunction · 0.85
to_stringFunction · 0.85
getThreadStateMethod · 0.80
signalMethod · 0.80
TypMethod · 0.45
DataMethod · 0.45
lockMethod · 0.45
unlockMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected