2000-03-27 19:53:43 +00:00
|
|
|
<!-- ##### SECTION Title ##### -->
|
|
|
|
cothreads
|
|
|
|
|
|
|
|
<!-- ##### SECTION Short_Description ##### -->
|
2000-11-07 21:24:12 +00:00
|
|
|
userspace threads
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
<!-- ##### SECTION Long_Description ##### -->
|
|
|
|
<para>
|
2000-11-07 21:24:12 +00:00
|
|
|
Cothreads are a simple user-space method for switching between
|
|
|
|
subtasks. They're based on setjmp()/longjmp() in their current form.
|
|
|
|
</para>
|
2000-03-27 19:53:43 +00:00
|
|
|
|
2000-11-07 21:24:12 +00:00
|
|
|
<para>
|
|
|
|
Cothreads are used for loop-based elements that pull data instead
|
|
|
|
of being fed with data. They can also be used to pull a specific region
|
|
|
|
of data out of their src element.
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### SECTION See_Also ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<!-- ##### MACRO COTHREAD_STACKSIZE ##### -->
|
|
|
|
<para>
|
2001-01-06 22:05:15 +00:00
|
|
|
The default stack size of a cothread.
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO COTHREAD_MAXTHREADS ##### -->
|
|
|
|
<para>
|
2000-11-07 21:24:12 +00:00
|
|
|
The maximum number of cothreads we are going to support.
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO STACK_SIZE ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO CURRENT_STACK_FRAME ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### STRUCT cothread_state ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2000-10-22 16:30:25 +00:00
|
|
|
@ctx:
|
|
|
|
@threadnum:
|
|
|
|
@func:
|
|
|
|
@argc:
|
|
|
|
@argv:
|
|
|
|
@flags:
|
|
|
|
@sp:
|
|
|
|
@top_sp:
|
|
|
|
@pc:
|
|
|
|
@jmp:
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
<!-- ##### STRUCT cothread_context ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2000-10-22 16:30:25 +00:00
|
|
|
@threads:
|
|
|
|
@nthreads:
|
|
|
|
@current:
|
2000-11-07 21:24:12 +00:00
|
|
|
@data:
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
<!-- ##### USER_FUNCTION cothread_func ##### -->
|
|
|
|
<para>
|
2000-11-11 15:13:50 +00:00
|
|
|
the function that will be called when the cothread starts. The function
|
|
|
|
prototype is like a main() function, so you can do whatever you want with
|
|
|
|
it.
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
2000-11-11 15:13:50 +00:00
|
|
|
@argc: a main-like argument count
|
|
|
|
@argv: a main-like array of arguments
|
|
|
|
@Returns: a return code
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### MACRO COTHREAD_STARTED ##### -->
|
|
|
|
<para>
|
2001-01-06 22:05:15 +00:00
|
|
|
Indicates the cothread is started.
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_init ##### -->
|
|
|
|
<para>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_create ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@ctx:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_setfunc ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
@func:
|
|
|
|
@argc:
|
|
|
|
@argv:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_switch ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
2000-12-28 21:42:23 +00:00
|
|
|
<!-- ##### FUNCTION cothread_getcurrent ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
<!-- ##### FUNCTION cothread_main ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@ctx:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2000-11-07 21:24:12 +00:00
|
|
|
<!-- ##### FUNCTION cothread_set_data ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
@key:
|
|
|
|
@data:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_get_data ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
@key:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|