1 | version="version systhreads.lib 0.1.0.0 Aug_2016"; |
---|
2 | category="General purpose"; |
---|
3 | info=" |
---|
4 | LIBRARY: systhreads.lib Primitives for Singular's multi-threaded objects |
---|
5 | AUTHOR: Reimer Behrends |
---|
6 | |
---|
7 | OVERVIEW: |
---|
8 | This library implements basic functionality for shared objects in a |
---|
9 | multi-threaded system, such as channels, shared tables & lists, and |
---|
10 | synchronization variables. |
---|
11 | |
---|
12 | KEYWORDS: parallel computing |
---|
13 | "; |
---|
14 | |
---|
15 | static proc mod_init() { |
---|
16 | LIB "systhreads.so"; |
---|
17 | } |
---|
18 | |
---|
19 | proc threadLoadLib(thread th, string libname) { |
---|
20 | threadExec(th, quote(load(eval(libname), "with"))); |
---|
21 | } |
---|
22 | |
---|
23 | proc threadExecFile(thread th, string file) { |
---|
24 | threadExec(th, quote(execute(read(eval(file))))); |
---|
25 | } |
---|
26 | |
---|
27 | proc threadExecString(thread th, string s) { |
---|
28 | threadExec(th, quote(execute(eval(s)))); |
---|
29 | } |
---|
30 | |
---|
31 | proc threadPoolLoadLib(threadpool th, string libname) { |
---|
32 | threadPoolExec(th, quote(load(eval(libname), "with"))); |
---|
33 | } |
---|
34 | |
---|
35 | proc threadPoolExecFile(threadpool th, string file) { |
---|
36 | threadPoolExec(th, quote(execute(read(eval(file))))); |
---|
37 | } |
---|
38 | |
---|
39 | proc threadPoolExecString(threadpool th, string s) { |
---|
40 | threadPoolExec(th, quote(execute(eval(s)))); |
---|
41 | } |
---|
42 | |
---|
43 | proc 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 | |
---|
54 | proc bindChannel(string name) { |
---|
55 | return(bindTypedSharedObject(name, "channel")); |
---|
56 | } |
---|
57 | |
---|
58 | proc bindAtomicTable(string name) { |
---|
59 | return(bindTypedSharedObject(name, "atomic_table")); |
---|
60 | } |
---|
61 | |
---|
62 | proc bindAtomicList(string name) { |
---|
63 | return(bindTypedSharedObject(name, "atomic_list")); |
---|
64 | } |
---|
65 | |
---|
66 | proc bindRegion(string name) { |
---|
67 | return(bindTypedSharedObject(name, "region")); |
---|
68 | } |
---|
69 | |
---|
70 | proc bindSyncVar(string name) { |
---|
71 | return(bindTypedSharedObject(name, "syncvar")); |
---|
72 | } |
---|
73 | |
---|
74 | // vim:filetype=singular |
---|