version="version systhreads.lib 4.2.0.0 Dec_2020 "; // $Id$ category="General purpose"; info=" LIBRARY: systhreads.lib Primitives for Singular's multi-threaded objects AUTHOR: Reimer Behrends OVERVIEW: This library implements basic functionality for shared objects in a multi-threaded system, such as channels, shared tables & lists, and synchronization variables. KEYWORDS: parallel computing "; static proc mod_init() { load("systhreads.so"); } proc threadLoadLib(thread th, string libname) { threadExec(th, quote(load(eval(libname), "with"))); } proc threadExecFile(thread th, string file) { threadExec(th, quote(execute(read(eval(file))))); } proc threadExecString(thread th, string s) { threadExec(th, quote(execute(eval(s)))); } proc threadPoolLoadLib(threadpool th, string libname) { threadPoolExec(th, quote(load(eval(libname), "with"))); } proc threadPoolExecFile(threadpool th, string file) { threadPoolExec(th, quote(execute(read(eval(file))))); } proc threadPoolExecString(threadpool th, string s) { threadPoolExec(th, quote(execute(eval(s)))); } proc bindTypedSharedObject(string name, string needed_type) { string actual_type = typeSharedObject(name); if (actual_type == needed_type) { return(bindSharedObject(name)); } else { if (actual_type == "undefined") { ERROR("bindTypedSharedObject: object '" + name + "' does not exist"); } } ERROR("bindTypedSharedObject: found " + actual_type + ", needed " + needed_type); } proc bindChannel(string name) { return(bindTypedSharedObject(name, "channel")); } proc bindAtomicTable(string name) { return(bindTypedSharedObject(name, "atomic_table")); } proc bindAtomicList(string name) { return(bindTypedSharedObject(name, "atomic_list")); } proc bindRegion(string name) { return(bindTypedSharedObject(name, "region")); } proc bindSyncVar(string name) { return(bindTypedSharedObject(name, "syncvar")); } // vim:filetype=singular