.TH "globus_callback_api" 3 "Thu Jan 12 2017" "Version 16.9" "globus_common" \" -*- nroff -*- .ad l .nh .SH NAME globus_callback_api .SH SYNOPSIS .br .PP .SS "Convenience Macros" .in +1c .ti -1c .RI "#define \fBglobus_callback_poll\fP(a)" .br .RI "Poll the global callback space\&. " .ti -1c .RI "#define \fBglobus_poll_blocking\fP()" .br .RI "Blocking poll of the global callback space\&. " .ti -1c .RI "#define \fBglobus_poll_nonblocking\fP()" .br .RI "Nonblocking poll of the global callback space\&. " .ti -1c .RI "#define \fBglobus_poll\fP()" .br .RI "Nonblocking poll of the global callback space\&. " .ti -1c .RI "#define \fBglobus_signal_poll\fP()" .br .RI "Wake up callback polling thread\&. " .ti -1c .RI "#define \fBglobus_callback_register_oneshot\fP( callback_handle, delay_time, callback_func, callback_user_arg)" .br .RI "Register a oneshot function in the global callback space\&. " .ti -1c .RI "#define \fBglobus_callback_register_periodic\fP( callback_handle, delay_time, period, callback_func, callback_user_arg)" .br .RI "Register a periodic function in the global callback space\&. " .ti -1c .RI "#define \fBglobus_callback_register_signal_handler\fP( signum, persist, callback_func, callback_user_arg)" .br .RI "Register a signal handler in the global callback space\&. " .in -1c .SS "Callback Prototypes" .in +1c .ti -1c .RI "typedef void(* \fBglobus_callback_func_t\fP) (void *user_arg)" .br .RI "Globus callback prototype\&. " .in -1c .SS "Oneshot Callbacks" .in +1c .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_register_oneshot\fP (\fBglobus_callback_handle_t\fP *callback_handle, const globus_reltime_t *delay_time, \fBglobus_callback_func_t\fP callback_func, void *callback_user_arg, \fBglobus_callback_space_t\fP space)" .br .RI "Register a oneshot some delay from now\&. " .in -1c .SS "Periodic Callbacks" .in +1c .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_register_periodic\fP (\fBglobus_callback_handle_t\fP *callback_handle, const globus_reltime_t *delay_time, const globus_reltime_t *period, \fBglobus_callback_func_t\fP callback_func, void *callback_user_arg, \fBglobus_callback_space_t\fP space)" .br .RI "Register a periodic callback\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_unregister\fP (\fBglobus_callback_handle_t\fP callback_handle, \fBglobus_callback_func_t\fP unregister_callback, void *unreg_arg, \fBglobus_bool_t\fP *active)" .br .RI "Unregister a callback\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_adjust_oneshot\fP (\fBglobus_callback_handle_t\fP callback_handle, const globus_reltime_t *new_delay)" .br .RI "Adjust the delay of a oneshot callback\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_adjust_period\fP (\fBglobus_callback_handle_t\fP callback_handle, const globus_reltime_t *new_period)" .br .RI "Adjust the period of a periodic callback\&. " .in -1c .SS "Callback Polling" .in +1c .ti -1c .RI "void \fBglobus_callback_space_poll\fP (const globus_abstime_t *timestop, \fBglobus_callback_space_t\fP space)" .br .RI "Poll for ready callbacks\&. " .ti -1c .RI "void \fBglobus_callback_signal_poll\fP ()" .br .RI "Signal the poll\&. " .in -1c .SS "Miscellaneous" .in +1c .ti -1c .RI "\fBglobus_bool_t\fP \fBglobus_callback_get_timeout\fP (globus_reltime_t *time_left)" .br .RI "Get the amount of time left in a callback\&. " .ti -1c .RI "\fBglobus_bool_t\fP \fBglobus_callback_has_time_expired\fP ()" .br .RI "See if there is remaining time in a callback\&. " .ti -1c .RI "\fBglobus_bool_t\fP \fBglobus_callback_was_restarted\fP ()" .br .RI "See if a callback has been restarted\&. " .in -1c .SH "Detailed Description" .PP .SH "Macro Definition Documentation" .PP .SS "#define globus_callback_poll(a)" .PP Poll the global callback space\&. Specifies the global space for \fBglobus_callback_space_poll()\fP\&. argument is the timeout .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_poll()\fP .RE .PP .SS "#define globus_callback_register_oneshot(callback_handle, delay_time, callback_func, callback_user_arg)" .PP Register a oneshot function in the global callback space\&. Specifies the global space for \fBglobus_callback_space_register_oneshot()\fP all other arguments are the same as specified there\&. .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_oneshot()\fP .RE .PP .SS "#define globus_callback_register_periodic(callback_handle, delay_time, period, callback_func, callback_user_arg)" .PP Register a periodic function in the global callback space\&. Specifies the global space for \fBglobus_callback_space_register_periodic()\fP all other arguments are the same as specified there\&. .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_periodic()\fP .RE .PP .SS "#define globus_callback_register_signal_handler(signum, persist, callback_func, callback_user_arg)" .PP Register a signal handler in the global callback space\&. Specifies the global space for \fBglobus_callback_space_register_signal_handler()\fP all other arguments are the same as specified there\&. .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_signal_handler()\fP .RE .PP .SS "#define globus_poll()" .PP Nonblocking poll of the global callback space\&. Specifies that \fBglobus_callback_space_poll()\fP should poll on the global space with an immediate timeout .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_poll()\fP .RE .PP .SS "#define globus_poll_blocking()" .PP Blocking poll of the global callback space\&. Specifies that \fBglobus_callback_space_poll()\fP should poll on the global space with an infinite timeout .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_poll()\fP .RE .PP .SS "#define globus_poll_nonblocking()" .PP Nonblocking poll of the global callback space\&. Specifies that \fBglobus_callback_space_poll()\fP should poll on the global space with an immediate timeout .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_poll()\fP .RE .PP .SS "#define globus_signal_poll()" .PP Wake up callback polling thread\&. Counterpart to \fBglobus_poll()\fP\&. .PP \fBSee also:\fP .RS 4 \fBglobus_callback_signal_poll()\fP .RE .PP .SH "Typedef Documentation" .PP .SS "typedef void(* globus_callback_func_t) (void *user_arg)" .PP Globus callback prototype\&. This is the signature of the function registered with the globus_callback_register_* calls\&. .PP If this is a periodic callback, it is guaranteed that the call canNOT be reentered unless globus_thread_blocking_space_will_block() is called (explicitly, or implicitly via \fBglobus_cond_wait()\fP)\&. Also, if \fBglobus_callback_unregister()\fP is called to cancel this periodic from within this callback, it is guaranteed that the callback will NOT be requeued again .PP If the function will block at all, the user should call \fBglobus_callback_get_timeout()\fP to see how long this function can safely block or call globus_thread_blocking_space_will_block() .PP \fBParameters:\fP .RS 4 \fIuser_arg\fP The user argument registered with this callback .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 void .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_oneshot()\fP .PP \fBglobus_callback_space_register_periodic()\fP .PP globus_thread_blocking_space_will_block() .PP \fBglobus_callback_get_timeout()\fP .RE .PP .SH "Function Documentation" .PP .SS "\fBglobus_result_t\fP globus_callback_adjust_oneshot (\fBglobus_callback_handle_t\fP callback_handle, const globus_reltime_t * new_delay)" .PP Adjust the delay of a oneshot callback\&. This function allows a user to adjust the delay of a previously registered callback\&. It is safe to call this within or outside of the callback that is being modified\&. .PP Note if the oneshot has already been fired, this function will still return GLOBUS_SUCCESS, but won't affect anything\&. .PP \fBParameters:\fP .RS 4 \fIcallback_handle\fP the handle received from a \fBglobus_callback_space_register_oneshot()\fP call .br \fInew_delay\fP The new delay from now\&. If NULL, then callback will be fired as soon as possible\&. .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_periodic()\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_adjust_period (\fBglobus_callback_handle_t\fP callback_handle, const globus_reltime_t * new_period)" .PP Adjust the period of a periodic callback\&. This function allows a user to adjust the period of a previously registered callback\&. It is safe to call this within or outside of the callback that is being modified\&. .PP This func also allows a user to effectively 'suspend' a periodic callback until another time by passing a period of NULL\&. The callback can later be resumed by passing in a new period\&. .PP Note that the callback will not be fired sooner than 'new_period' from now\&. A 'suspended' callback must still be unregistered to free its resources\&. .PP \fBParameters:\fP .RS 4 \fIcallback_handle\fP the handle received from a \fBglobus_callback_space_register_periodic()\fP call .br \fInew_period\fP The new period\&. If NULL or globus_i_reltime_infinity, then callback will be 'suspended' as soon as the last running instance of it returns\&. .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_periodic()\fP .RE .PP .SS "\fBglobus_bool_t\fP globus_callback_get_timeout (globus_reltime_t * time_left)" .PP Get the amount of time left in a callback\&. This function retrieves the remaining time a callback is allowed to run\&. If a callback has already timed out, time_left will be set to zero and GLOBUS_TRUE returned\&. This function is intended to be called within a callback's stack, but is harmless to call anywhere (will return GLOBUS_FALSE and an infinite time_left) .PP \fBParameters:\fP .RS 4 \fItime_left\fP storage for the remaining time\&. .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_FALSE if time remaining .IP "\(bu" 2 GLOBUS_TRUE if already timed out .PP .RE .PP .SS "\fBglobus_bool_t\fP globus_callback_has_time_expired ()" .PP See if there is remaining time in a callback\&. This function returns GLOBUS_TRUE if the running time of a callback has already expired\&. This function is intended to be called within a callback's stack, but is harmless to call anywhere (will return GLOBUS_FALSE) .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_FALSE if time remaining .IP "\(bu" 2 GLOBUS_TRUE if already timed out .PP .RE .PP .SS "void globus_callback_signal_poll ()" .PP Signal the poll\&. This function signals \fBglobus_callback_space_poll()\fP that something has changed and it should return to its caller as soon as possible\&. .PP In general, you never need to call this function directly\&. It is called (when necessary) by \fBglobus_cond_signal()\fP or globus_cond_broadcast\&. The only case in which a user may wish to call this explicitly is if the application has no aspirations of ever being built threaded\&. .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 void .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_poll()\fP .RE .PP .SS "void globus_callback_space_poll (const globus_abstime_t * timestop, \fBglobus_callback_space_t\fP space)" .PP Poll for ready callbacks\&. This function is used to poll for registered callbacks\&. .PP For non-threaded builds, callbacks are not/can not be delivered unless this is called\&. Any call to this can cause callbacks registered with the 'global' space to be fired\&. Whereas callbacks registered with a user's space will only be delivered when this is called with that space\&. .PP For threaded builds, this only needs to be called to poll user spaces with behavior == GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE\&. The 'global' space and other user spaces are constantly polled in a separate thread\&. (If it is called in a threaded build for these spaces, it will just yield its thread) .PP In general, you never need to call this function directly\&. It is called (when necessary) by \fBglobus_cond_wait()\fP\&. The only case in which a user may wish to call this explicitly is if the application has no aspirations of ever being built threaded\&. .PP This function (when not yielding) will block up to timestop or until \fBglobus_callback_signal_poll()\fP is called by one of the fired callbacks\&. It will always try and kick out ready callbacks, regardless of the timestop\&. .PP \fBParameters:\fP .RS 4 \fItimestop\fP The time to block until\&. If this is NULL or less than the cuurent time, an attempt to fire only ready callbacks is made (no blocking)\&. .br \fIspace\fP The callback space to poll\&. Note: regardless of what space is passed here, the 'global' space is also always polled\&. .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 void .PP .RE .PP \fBSee also:\fP .RS 4 \fBGlobus Callback Spaces\fP .PP \fBglobus_condattr_setspace()\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_register_oneshot (\fBglobus_callback_handle_t\fP * callback_handle, const globus_reltime_t * delay_time, \fBglobus_callback_func_t\fP callback_func, void * callback_user_arg, \fBglobus_callback_space_t\fP space)" .PP Register a oneshot some delay from now\&. This function registers the callback_func to start some delay_time from now\&. .PP \fBParameters:\fP .RS 4 \fIcallback_handle\fP Storage for a handle\&. This may be NULL\&. If it is NOT NULL, you must unregister the callback to reclaim resources\&. .br \fIdelay_time\fP The relative time from now to fire this callback\&. If NULL, will fire as soon as possible .br \fIcallback_func\fP the user func to call .br \fIcallback_user_arg\fP user arg that will be passed to callback .br \fIspace\fP The space with which to register this callback .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_func_t\fP .PP \fBGlobus Callback Spaces\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_register_periodic (\fBglobus_callback_handle_t\fP * callback_handle, const globus_reltime_t * delay_time, const globus_reltime_t * period, \fBglobus_callback_func_t\fP callback_func, void * callback_user_arg, \fBglobus_callback_space_t\fP space)" .PP Register a periodic callback\&. This function registers a periodic callback_func to start some delay_time and run every period from then\&. .PP \fBParameters:\fP .RS 4 \fIcallback_handle\fP Storage for a handle\&. This may be NULL\&. If it is NOT NULL, you must cancel the periodic to reclaim resources\&. .br \fIdelay_time\fP The relative time from now to fire this callback\&. If NULL, will fire the first callback as soon as possible .br \fIperiod\fP The relative period of this callback .br \fIcallback_func\fP the user func to call .br \fIcallback_user_arg\fP user arg that will be passed to callback .br \fIspace\fP The space with which to register this callback .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_unregister()\fP .PP \fBglobus_callback_func_t\fP .PP \fBglobus_callback_spaces\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_unregister (\fBglobus_callback_handle_t\fP callback_handle, \fBglobus_callback_func_t\fP unregister_callback, void * unreg_arg, \fBglobus_bool_t\fP * active)" .PP Unregister a callback\&. This function will cancel a callback and free the resources associcated with the callback handle\&. If the callback was able to be canceled immediately (or if it has already run), GLOBUS_SUCCESS is returned and it is guaranteed that there are no running instances of the callback\&. .PP If the callback is currently running (or unstoppably about to be run), then the callback is prevented from being requeued, but, the 'official' cancel is deferred until the last running instance of the callback returns\&. If you need to know when the callback is guaranteed to have been canceled, pass an unregister callback\&. .PP If you would like to know if you unregistered a callback before it ran, pass storage for a boolean 'active'\&. This will be GLOBUS_TRUE if callback was running\&. GLOBUS_FALSE otherwise\&. .PP \fBParameters:\fP .RS 4 \fIcallback_handle\fP the handle received from a globus_callback_space_register_*() call .br \fIunregister_callback\fP the function to call when the callback has been canceled and there are no running instances of it\&. This will be delivered to the same space used in the register call\&. .br \fIunreg_arg\fP user arg that will be passed to the unregister callback .br \fIactive\fP storage for an indication of whether the callback was running when this call was made .RE .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also:\fP .RS 4 \fBglobus_callback_space_register_periodic()\fP .PP \fBglobus_callback_func_t\fP .RE .PP .SS "\fBglobus_bool_t\fP globus_callback_was_restarted ()" .PP See if a callback has been restarted\&. If the callback is a oneshot, this merely means the callback called globus_thread_blocking_space_will_block (or \fBglobus_cond_wait()\fP at some point\&. .PP For a periodic, it signifies the same and also that the periodic has been requeued\&. This means that the callback function may be reentered if the period is short enough (on a threaded build) .PP \fBReturns:\fP .RS 4 .IP "\(bu" 2 GLOBUS_FALSE if not restarted .IP "\(bu" 2 GLOBUS_TRUE if restarted .PP .RE .PP .SH "Author" .PP Generated automatically by Doxygen for globus_common from the source code\&.