.TH "globus_callback_spaces" 3 "Version 18.14" "globus_common" \" -*- nroff -*- .ad l .nh .SH NAME globus_callback_spaces \- Globus Callback Spaces .PP \- Globus Callback Spaces\&. .SH SYNOPSIS .br .PP .SS "Miscellaneous" .in +1c .ti -1c .RI "enum \fBglobus_callback_space_behavior_t\fP { \fBGLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE\fP, \fBGLOBUS_CALLBACK_SPACE_BEHAVIOR_SERIALIZED\fP, \fBGLOBUS_CALLBACK_SPACE_BEHAVIOR_THREADED\fP }" .br .RI "Callback space behaviors describe how a space behaves\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_init\fP (\fBglobus_callback_space_t\fP *space, \fBglobus_callback_space_attr_t\fP attr)" .br .RI "Initialize a user space\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_reference\fP (\fBglobus_callback_space_t\fP space)" .br .RI "Take a reference to a space\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_destroy\fP (\fBglobus_callback_space_t\fP space)" .br .RI "Destroy a reference to a user space\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_attr_init\fP (\fBglobus_callback_space_attr_t\fP *attr)" .br .RI "Initialize a space attr\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_attr_destroy\fP (\fBglobus_callback_space_attr_t\fP attr)" .br .RI "Destroy a space attr\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_attr_set_behavior\fP (\fBglobus_callback_space_attr_t\fP attr, \fBglobus_callback_space_behavior_t\fP behavior)" .br .RI "Set the behavior of a space\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_attr_get_behavior\fP (\fBglobus_callback_space_attr_t\fP attr, \fBglobus_callback_space_behavior_t\fP *behavior)" .br .RI "Get the behavior associated with an attr\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_get\fP (\fBglobus_callback_space_t\fP *space)" .br .RI "Retrieve the space of a currently running callback\&. " .ti -1c .RI "int \fBglobus_callback_space_get_depth\fP (\fBglobus_callback_space_t\fP space)" .br .RI "Retrieve the current nesting level of a space\&. " .ti -1c .RI "\fBglobus_bool_t\fP \fBglobus_callback_space_is_single\fP (\fBglobus_callback_space_t\fP space)" .br .RI "See if the specified space is a single threaded behavior space\&. " .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\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_space_register_signal_handler\fP (int signum, \fBglobus_bool_t\fP persist, \fBglobus_callback_func_t\fP callback_func, void *callback_user_arg, \fBglobus_callback_space_t\fP space)" .br .RI "Fire a callback when the specified signal is received\&. " .ti -1c .RI "\fBglobus_result_t\fP \fBglobus_callback_unregister_signal_handler\fP (int signum, \fBglobus_callback_func_t\fP unregister_callback, void *unreg_arg)" .br .RI "Unregister a signal handling callback\&. " .ti -1c .RI "void \fBglobus_callback_add_wakeup_handler\fP (void(*wakeup)(void *), void *user_arg)" .br .RI "Register a wakeup handler with callback library\&. " .ti -1c .RI "#define \fBGLOBUS_CALLBACK_GLOBAL_SPACE\fP" .br .RI "Global callback space\&. " .ti -1c .RI "#define \fBGLOBUS_SIGNAL_INTERRUPT\fP" .br .in -1c .SH "Detailed Description" .PP Globus Callback Spaces\&. .SH "Macro Definition Documentation" .PP .SS "#define GLOBUS_CALLBACK_GLOBAL_SPACE" .PP Global callback space\&. The 'global' space handle\&. .PP This is the default space handle implied if no spaces are explicitly created\&. .SS "#define GLOBUS_SIGNAL_INTERRUPT" Use this to trap interrupts (SIGINT on unix)\&. In the future, this will also map to handle ctrl-C on win32\&. .SH "Enumeration Type Documentation" .PP .SS "enum \fBglobus_callback_space_behavior_t\fP" .PP Callback space behaviors describe how a space behaves\&. In a non-threaded build all spaces exhibit a behavior == _BEHAVIOR_SINGLE\&. Setting a specific behavior in this case is ignored\&. .PP In a threaded build, _BEHAVIOR_SINGLE retains all the rules and behaviors of a non-threaded build while _BEHAVIOR_THREADED makes the space act as the global space\&. .PP Setting a space's behavior to _BEHAVIOR_SINGLE guarantees that the poll protection will always be there and all callbacks are serialized and only kicked out when polled for\&. In a threaded build, it is still necessary to poll for callbacks in a _BEHAVIOR_SINGLE space\&. (\fBglobus_cond_wait()\fP will take care of this for you also) .PP Setting a space's behavior to _BEHAVIOR_SERIALIZED guarantees that the poll protection will always be there and all callbacks are serialized\&. In a threaded build, it is NOT necessary to poll for callbacks in a _BEHAVIOR_SERIALIZED space\&. Callbacks in this space will be delivered as soon as possible, but only one outstanding (and unblocked) callback will be allowed at any time\&. .PP Setting a space's behavior to _BEHAVIOR_THREADED allows the user to have the poll protection provided by spaces when built non-threaded, yet, be fully threaded when built threaded (where poll protection is not needed) .PP \fBEnumerator\fP .in +1c .TP \fB\fIGLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE \fP\fP The default behavior\&. Indicates that you always want poll protection and single threaded behavior (callbacks need to be explicitly polled for .TP \fB\fIGLOBUS_CALLBACK_SPACE_BEHAVIOR_SERIALIZED \fP\fP Indicates that you want poll protection and all callbacks to be serialized (but they do not need to be polled for in a threaded build) .TP \fB\fIGLOBUS_CALLBACK_SPACE_BEHAVIOR_THREADED \fP\fP Indicates that you only want poll protection .SH "Function Documentation" .PP .SS "void globus_callback_add_wakeup_handler (void(*)(void *) wakeup, void * user_arg)" .PP Register a wakeup handler with callback library\&. This is really only needed in non-threaded builds, but for cross builds should be used everywhere that a callback may sleep for an extended period of time\&. .PP An example use is for an io poller that sleeps indefinitely on select()\&. If the callback library receives a signal that it needs to deliver asap, it will call the wakeup handler(s), These wakeup handlers must run as though they were called from a signal handler (don't use any thread utilities)\&. The io poll example will likely write a single byte to a pipe that select() is monitoring\&. .PP This handler will not be unregistered until the callback library is deactivated (via common)\&. .PP \fBParameters\fP .RS 4 \fIwakeup\fP function to call when callback library needs you to return asap from any blocked callbacks\&. .br \fIuser_arg\fP user data that will be passed along in the wakeup handler .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 "\fBglobus_result_t\fP globus_callback_space_attr_destroy (\fBglobus_callback_space_attr_t\fP attr)" .PP Destroy a space attr\&. .PP \fBParameters\fP .RS 4 \fIattr\fP attr to destroy, previously initialized with \fBglobus_callback_space_attr_init()\fP .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT on NULL attr .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also\fP .RS 4 \fBglobus_callback_space_attr_init()\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_attr_get_behavior (\fBglobus_callback_space_attr_t\fP attr, \fBglobus_callback_space_behavior_t\fP * behavior)" .PP Get the behavior associated with an attr\&. Note: for a non-threaded build, this will always pass back a behavior == GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE\&. .PP \fBParameters\fP .RS 4 \fIattr\fP attr on which to query behavior .br \fIbehavior\fP storage for the behavior .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_attr_init (\fBglobus_callback_space_attr_t\fP * attr)" .PP Initialize a space attr\&. Currently, the only attr to set is the behavior\&. The default behavior associated with this attr is GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE .PP \fBParameters\fP .RS 4 \fIattr\fP storage for the initialized attr\&. Must be destroyed with \fBglobus_callback_space_attr_destroy()\fP .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT on NULL attr .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_attr_set_behavior (\fBglobus_callback_space_attr_t\fP attr, \fBglobus_callback_space_behavior_t\fP behavior)" .PP Set the behavior of a space\&. .PP \fBParameters\fP .RS 4 \fIattr\fP attr to associate behavior with .br \fIbehavior\fP desired behavior .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also\fP .RS 4 \fBglobus_callback_space_behavior_t\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_destroy (\fBglobus_callback_space_t\fP space)" .PP Destroy a reference to a user space\&. This will destroy a reference to a previously initialized space\&. Space will not actually be destroyed until all callbacks registered with this space have been run and unregistered (if the user has a handle to that callback) AND all references (from \fBglobus_callback_space_reference()\fP) have been destroyed\&. .PP \fBParameters\fP .RS 4 \fIspace\fP space to destroy, previously initialized by \fBglobus_callback_space_init()\fP or referenced with \fBglobus_callback_space_reference()\fP .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_SPACE .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also\fP .RS 4 \fBglobus_callback_space_init()\fP .PP \fBglobus_callback_space_reference()\fP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_get (\fBglobus_callback_space_t\fP * space)" .PP Retrieve the space of a currently running callback\&. .PP \fBParameters\fP .RS 4 \fIspace\fP storage for the handle to the space currently running .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT on NULL space .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_NO_ACTIVE_CALLBACK .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP .SS "int globus_callback_space_get_depth (\fBglobus_callback_space_t\fP space)" .PP Retrieve the current nesting level of a space\&. .PP \fBParameters\fP .RS 4 \fIspace\fP The space to query\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 the current nesting level .IP "\(bu" 2 -1 on invalid space .PP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_init (\fBglobus_callback_space_t\fP * space, \fBglobus_callback_space_attr_t\fP attr)" .PP Initialize a user space\&. This creates a user space\&. .PP \fBParameters\fP .RS 4 \fIspace\fP storage for the initialized space handle\&. This must be destroyed with \fBglobus_callback_space_destroy()\fP .br \fIattr\fP a space attr describing desired behaviors\&. If GLOBUS_NULL, the default behavior of GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE is assumed\&. This attr is copied into the space, so it is acceptable to destroy the attr as soon as it is no longer needed .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT on NULL space .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP \fBSee also\fP .RS 4 \fBglobus_condattr_setspace()\fP .PP globus_io_attr_set_callback_space() .RE .PP .SS "\fBglobus_bool_t\fP globus_callback_space_is_single (\fBglobus_callback_space_t\fP space)" .PP See if the specified space is a single threaded behavior space\&. .PP \fBParameters\fP .RS 4 \fIspace\fP the space to query .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_TRUE if space's behavior is _BEHAVIOR_SINGLE .IP "\(bu" 2 GLOBUS_FALSE otherwise .PP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_reference (\fBglobus_callback_space_t\fP space)" .PP Take a reference to a space\&. A library which has been 'given' a space to provide callbacks on would use this to take a reference on the user's space\&. This prevents mayhem should a user destroy a space before the library is done with it\&. This reference should be destroyed with \fBglobus_callback_space_destroy()\fP (think dup()) .PP \fBParameters\fP .RS 4 \fIspace\fP space to reference .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_SPACE .IP "\(bu" 2 GLOBUS_SUCCESS .PP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_space_register_signal_handler (int signum, \fBglobus_bool_t\fP persist, \fBglobus_callback_func_t\fP callback_func, void * callback_user_arg, \fBglobus_callback_space_t\fP space)" .PP Fire a callback when the specified signal is received\&. Note that there is a tiny delay between the time this call returns and the signal is actually handled by this library\&. It is likely that, if the signal was received the instant the call returned, it will be lost (this is normally not an issue, since you would call this in your startup code anyway) .PP \fBParameters\fP .RS 4 \fIsignum\fP The signal to receive\&. The following signals are not allowed: SIGKILL, SIGSEGV, SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGIOT, SIGPIPE, SIGEMT, SIGSYS, SIGTRAP, SIGSTOP, SIGCONT, and SIGWAITING .br \fIpersist\fP If GLOBUS_TRUE, keep this callback registered for multiple signals\&. If GLOBUS_FALSE, the signal handler will automatically be unregistered once the signal has been received\&. .br \fIcallback_func\fP the user func to call when a signal is received .br \fIcallback_user_arg\fP user arg that will be passed to callback .br \fIspace\fP the space to deliver callbacks to\&. .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_SPACE .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT .IP "\(bu" 2 GLOBUS_SUCCESS otherwise .PP .RE .PP .SS "\fBglobus_result_t\fP globus_callback_unregister_signal_handler (int signum, \fBglobus_callback_func_t\fP unregister_callback, void * unreg_arg)" .PP Unregister a signal handling callback\&. .PP \fBParameters\fP .RS 4 \fIsignum\fP The signal to unregister\&. .br \fIunregister_callback\fP the function to call when the callback has been canceled and there are no running instances of it (may be NULL)\&. This will be delivered to the same space used in the register call\&. .br \fIunreg_arg\fP user arg that will be passed to callback .RE .PP \fBReturns\fP .RS 4 .IP "\(bu" 2 GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT if this signal was registered with persist == false, then there is a race between a signal actually being caught and therefore automatically unregistered and the attempt to manually unregister it\&. If that race occurs, you will receive this error just as you would for any signal not registered\&. .IP "\(bu" 2 GLOBUS_SUCCESS otherwise .PP .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\&.