source: git/Singular/LIB/systhreads.lib @ f0f0003

fieker-DuValspielwiese
Last change on this file since f0f0003 was f0f0003, checked in by Reimer Behrends <behrends@…>, 5 years ago
Libthread implementation.
  • Property mode set to 100644
File size: 1.9 KB
Line 
1version="version systhreads.lib 0.1.0.0 Aug_2016";
2category="General purpose";
3info="
4LIBRARY: systhreads.lib Primitives for Singular's multi-threaded objects
5AUTHOR: Reimer Behrends
6
7OVERVIEW:
8This library implements basic functionality for shared objects in a
9multi-threaded system, such as channels, shared tables & lists, and
10synchronization variables.
11
12KEYWORDS: parallel computing
13";
14
15static proc mod_init() {
16  LIB "systhreads.so";
17}
18
19proc threadLoadLib(thread th, string libname) {
20  threadExec(th, quote(load(eval(libname), "with")));
21}
22
23proc threadExecFile(thread th, string file) {
24  threadExec(th, quote(execute(read(eval(file)))));
25}
26
27proc threadExecString(thread th, string s) {
28  threadExec(th, quote(execute(eval(s))));
29}
30
31proc threadPoolLoadLib(threadpool th, string libname) {
32  threadPoolExec(th, quote(load(eval(libname), "with")));
33}
34
35proc threadPoolExecFile(threadpool th, string file) {
36  threadPoolExec(th, quote(execute(read(eval(file)))));
37}
38
39proc threadPoolExecString(threadpool th, string s) {
40  threadPoolExec(th, quote(execute(eval(s))));
41}
42
43proc bindTypedSharedObject(string name, string needed_type) {
44  string actual_type = typeSharedObject(name);
45  if (actual_type == needed_type) {
46    return(bindSharedObject(name));
47  } else { if (actual_type == "undefined") {
48    ERROR("bindTypedSharedObject: object '" + name + "' does not exist");
49  } }
50  ERROR("bindTypedSharedObject: found " + actual_type +
51        ", needed " + needed_type);
52}
53
54proc bindChannel(string name) {
55  return(bindTypedSharedObject(name, "channel"));
56}
57
58proc bindAtomicTable(string name) {
59  return(bindTypedSharedObject(name, "atomic_table"));
60}
61
62proc bindAtomicList(string name) {
63  return(bindTypedSharedObject(name, "atomic_list"));
64}
65
66proc bindRegion(string name) {
67  return(bindTypedSharedObject(name, "region"));
68}
69
70proc bindSyncVar(string name) {
71  return(bindTypedSharedObject(name, "syncvar"));
72}
73
74// vim:filetype=singular
Note: See TracBrowser for help on using the repository browser.