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>
|
|
|
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### 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:
|
|
|
|
|
|
|
|
|
2001-05-27 14:33:30 +00:00
|
|
|
<!-- ##### FUNCTION cothread_unlock ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_current_main ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_lock ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ##### FUNCTION cothread_trylock ##### -->
|
|
|
|
<para>
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
@thread:
|
|
|
|
@Returns:
|
|
|
|
|
|
|
|
|