source: project/wiki/eggref/4/pthreads @ 33106

Last change on this file since 33106 was 33106, checked in by svnwiki, 4 years ago

Anonymous wiki edit for IP [78.51.158.166]:

File size: 2.3 KB
Line 
1== pthreads
2
3Maintain and talk to a pthread pool.
4
5== Overview
6
7Most of the egg's work is done in the startup: a pool of {{pthreads}} waiting for a job is initialized.
8
9
10== Issues
11
12* Requires recent chicken version 4.11 or at least git master rev. 8294683 of 2016-01-14
13
14* Starts currently 5 pthreads. TBD: make this configurable and start as many threads a the operating system configured processors are available.
15
16* The Scheme API is not yet tested.
17
18
19== API
20
21=== C
22
23<macro>typedef int (*C_pthread_request_function_t)(void *);</macro>
24
25<procedure>extern int start_asynchronous_request(C_pthread_request_function_t function, void *data, void *callback);</procedure>
26
27Send {{function}} to be executed at any thread of the pool.  {{Function}} must accept one argument, the {{data}}.  {{Callback}} must be a {{C_GC_ROOT}} object holding the procedure to receive the result for {{function}}.
28
29<procedure>void C_interrupt_call(void *callback, void *result, void *value)</procedure>
30
31Predecessor of [[concurrent-native-callbacks]].  Tell CHICKEN to call the procedure held in the {{C_GC_ROOT}} object {{callback}} on the result of applying the {{C_GC_ROOT}} object {{result}} to {{value}}.
32
33=== Scheme
34
35<procedure>(pool-send! JOB DATA CALLBACK) -> undefined</procedure>
36
37All arguments given as non-null-c-pointer.
38
39{{JOB}}: The C procedure to call
40
41{{DATA}}: Opaque pointer for parameter passing.
42
43{{CALLBACK}}: Pointer to callback procedure wrapped in a {{C_GC_ROOT}}.
44The callback is called with the value returned by {{JOB}}.
45
46== Examples
47
48* [[https://github.com/0-8-15/sqlite3pth|sqlite3pth egg repository]] on github.
49
50        (define sqlite3-start-prepare
51          (foreign-lambda*
52           void
53           ((<sqlite3-prepare-args> s) (nonnull-c-pointer callback))
54           "start_asynchronous_request(
55             pthread_sqlite3_prepare, s, callback);"))
56
57* Ask the author for alpha code running fuse on pthreads.
58
59== About this egg
60
61=== Author
62
63Jörg F. Wittenberger
64
65=== Source Code
66
67The [[https://github.com/0-8-15/pthreads|pthreds egg repository]] is maintained on github.
68
69=== Version History
70
71Version 0.1: Initial import.
72
73Before: This code was ported from an RScheme module of the same author several years ago.
74Since it's been used in [[http://ball.askemos.org|Askemos/BALL]].
75Years later, in 2010, it was converted into an module of it's own.
76
77=== License
78
79BSD
Note: See TracBrowser for help on using the repository browser.