ct_install_post_function

The ct_install_post_function function installs a user exit that the scheduler will invoke immediately after running each thread's own callback function.

Prototype:

Ct_user_exit ct_install_post_function( Ct_user_exit func );

Parameters:

func
A pointer to a callback function taking a void * as a parameter and returning an int. The function should return either CT_OKAY to indicate success or CT_ERROR to indicate failure.

Return Value:

A pointer to the previous post-thread user exit function.

Discussion:

For convenience, the ct.h header declares a typedef Ct_user_exit for the pointer type received and returned by this function.

Immediately after invoking each thread's own callback function, the scheduler invokes the post-thread user exit, if one is installed, passing it the same void pointer that it passed to the thread's own callback function.

A post-thread user exit executes fully in the context of the thread preceding it. For example, if the user exit calls ct_self(), it receives the same return value that the preceding thread would have received. It can terminate that thread by calling ct_exit(). Because it receives the same void pointer as the thread's own callback function, it can access the same data.

If the application saves the return value of ct_install_post_function(), it can restore the previous user exit.

The application can disable whatever post-thread user exit is in effect by passing a null pointer to ct_install_post_function().

See also: ct_install_pre_function()

Restrictions:

The application may call ct_install_post_function() at any time, although it is pointless for it to do so once the scheduler has terminated.
Home