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 CURRENT_STACK_FRAME ##### -->
|
|
|
|
<para>
|
2001-10-19 22:49:35 +00:00
|
|
|
Get the current stack frame.
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### STRUCT cothread_state ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2000-10-22 16:30:25 +00:00
|
|
|
@ctx:
|
|
|
|
@threadnum:
|
|
|
|
@func:
|
|
|
|
@argc:
|
|
|
|
@argv:
|
|
|
|
@flags:
|
|
|
|
@sp:
|
2001-05-25 21:00:07 +00:00
|
|
|
@jmp:
|
2000-10-22 16:30:25 +00:00
|
|
|
@top_sp:
|
|
|
|
@pc:
|
2000-03-27 19:53:43 +00:00
|
|
|
|
|
|
|
<!-- ##### STRUCT cothread_context ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### 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>
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### MACRO COTHREAD_DESTROYED ##### -->
|
2000-03-27 19:53:43 +00:00
|
|
|
<para>
|
2001-12-28 20:27:59 +00:00
|
|
|
Indicates the cothread is destroyed.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_context_init ##### -->
|
|
|
|
<para>
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_context_free ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@ctx:
|
|
|
|
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
<!-- ##### FUNCTION cothread_create ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@ctx:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_free ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
<!-- ##### FUNCTION cothread_setfunc ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
@func:
|
|
|
|
@argc:
|
|
|
|
@argv:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_stop ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
<!-- ##### FUNCTION cothread_switch ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_set_data ##### -->
|
2000-12-28 21:42:23 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
@thread:
|
|
|
|
@key:
|
|
|
|
@data:
|
2000-12-28 21:42:23 +00:00
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_get_data ##### -->
|
2000-03-27 19:53:43 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
@thread:
|
|
|
|
@key:
|
2000-03-27 19:53:43 +00:00
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_lock ##### -->
|
2000-11-07 21:24:12 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_trylock ##### -->
|
2000-11-07 21:24:12 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2001-05-27 14:33:30 +00:00
|
|
|
<!-- ##### FUNCTION cothread_unlock ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_main ##### -->
|
2001-05-27 14:33:30 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
@ctx:
|
2001-05-27 14:33:30 +00:00
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_current_main ##### -->
|
2001-05-27 14:33:30 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
@Returns:
|
2001-05-27 14:33:30 +00:00
|
|
|
|
|
|
|
|
2001-12-28 20:27:59 +00:00
|
|
|
<!-- ##### FUNCTION cothread_current ##### -->
|
2001-05-27 14:33:30 +00:00
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|