Loading...
Searching...
No Matches
globus_callback.h
Go to the documentation of this file.
/*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GLOBUS_CALLBACK_H
#define GLOBUS_CALLBACK_H
#include "globus_common_include.h"
#include "globus_module.h"
#include "globus_time.h"
#ifdef __cplusplus
extern "C" {
#endif
extern
globus_module_descriptor_t globus_i_callback_module;
#define GLOBUS_CALLBACK_MODULE (&globus_i_callback_module)
#define GLOBUS_POLL_MODULE GLOBUS_CALLBACK_MODULE
typedef enum
{
GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE = 1024,
GLOBUS_CALLBACK_ERROR_INVALID_SPACE,
GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC,
GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT,
GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED,
GLOBUS_CALLBACK_ERROR_NO_ACTIVE_CALLBACK
} globus_callback_error_type_t;
typedef int globus_callback_handle_t;
typedef int globus_callback_space_t;
typedef struct globus_l_callback_space_attr_s * globus_callback_space_attr_t;
/* @{ */
#define globus_callback_poll(a) \
globus_callback_space_poll((a), GLOBUS_CALLBACK_GLOBAL_SPACE)
#define globus_poll_blocking() \
globus_callback_poll(&globus_i_abstime_infinity)
#define globus_poll_nonblocking() \
globus_callback_poll(&globus_i_abstime_zero)
#define globus_poll() \
globus_poll_nonblocking()
#define globus_signal_poll() \
globus_callback_signal_poll()
#define globus_callback_register_oneshot( \
callback_handle, \
delay_time, \
callback_func, \
callback_user_arg) \
globus_callback_space_register_oneshot( \
(callback_handle), \
(delay_time), \
(callback_func), \
(callback_user_arg), \
GLOBUS_CALLBACK_GLOBAL_SPACE)
#define globus_callback_register_periodic( \
callback_handle, \
delay_time, \
period, \
callback_func, \
callback_user_arg) \
globus_callback_space_register_periodic( \
(callback_handle), \
(delay_time), \
(period), \
(callback_func), \
(callback_user_arg), \
GLOBUS_CALLBACK_GLOBAL_SPACE)
#define globus_callback_register_signal_handler( \
signum, \
persist, \
callback_func, \
callback_user_arg) \
globus_callback_space_register_signal_handler( \
(signum), \
(persist), \
(callback_func), \
(callback_user_arg), \
GLOBUS_CALLBACK_GLOBAL_SPACE)
/* @} */
/* @{ */
typedef
void
(*globus_callback_func_t)(
void * user_arg);
/* @} */
/* @{ */
globus_result_t
globus_callback_space_register_oneshot(
globus_callback_handle_t * callback_handle,
const globus_reltime_t * delay_time,
globus_callback_func_t callback_func,
void * callback_user_arg,
globus_callback_space_t space);
/* @} */
/* @{ */
globus_result_t
globus_callback_space_register_periodic(
globus_callback_handle_t * callback_handle,
const globus_reltime_t * delay_time,
const globus_reltime_t * period,
globus_callback_func_t callback_func,
void * callback_user_arg,
globus_callback_space_t space);
globus_result_t
globus_callback_unregister(
globus_callback_handle_t callback_handle,
globus_callback_func_t unregister_callback,
void * unreg_arg,
globus_bool_t * active);
globus_result_t
globus_callback_adjust_oneshot(
globus_callback_handle_t callback_handle,
const globus_reltime_t * new_delay);
globus_result_t
globus_callback_adjust_period(
globus_callback_handle_t callback_handle,
const globus_reltime_t * new_period);
/* @} */
/* @{ */
void
globus_callback_space_poll(
const globus_abstime_t * timestop,
globus_callback_space_t space);
void
globus_callback_signal_poll();
/* @} */
/* @{ */
globus_bool_t
globus_callback_get_timeout(
globus_reltime_t * time_left);
globus_bool_t
globus_callback_has_time_expired();
globus_bool_t
globus_callback_was_restarted();
/* @} */
#define GLOBUS_CALLBACK_GLOBAL_SPACE -2
typedef enum
{
GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE,
GLOBUS_CALLBACK_SPACE_BEHAVIOR_SERIALIZED,
GLOBUS_CALLBACK_SPACE_BEHAVIOR_THREADED
} globus_callback_space_behavior_t;
globus_result_t
globus_callback_space_init(
globus_callback_space_t * space,
globus_callback_space_attr_t attr);
globus_result_t
globus_callback_space_reference(
globus_callback_space_t space);
globus_result_t
globus_callback_space_destroy(
globus_callback_space_t space);
globus_result_t
globus_callback_space_attr_init(
globus_callback_space_attr_t * attr);
globus_result_t
globus_callback_space_attr_destroy(
globus_callback_space_attr_t attr);
globus_result_t
globus_callback_space_attr_set_behavior(
globus_callback_space_attr_t attr,
globus_callback_space_behavior_t behavior);
globus_result_t
globus_callback_space_attr_get_behavior(
globus_callback_space_attr_t attr,
globus_callback_space_behavior_t * behavior);
globus_result_t
globus_callback_space_get(
globus_callback_space_t * space);
int
globus_callback_space_get_depth(
globus_callback_space_t space);
globus_bool_t
globus_callback_space_is_single(
globus_callback_space_t space);
#ifdef SIGINT
#define GLOBUS_SIGNAL_INTERRUPT SIGINT
#else
#define GLOBUS_SIGNAL_INTERRUPT 0
#endif
globus_result_t
globus_callback_space_register_signal_handler(
int signum,
globus_bool_t persist,
globus_callback_func_t callback_func,
void * callback_user_arg,
globus_callback_space_t space);
globus_result_t
globus_callback_unregister_signal_handler(
int signum,
globus_callback_func_t unregister_callback,
void * unreg_arg);
void
globus_callback_add_wakeup_handler(
void (*wakeup)(void *),
void * user_arg);
#ifdef __cplusplus
}
#endif
#endif /* GLOBUS_CALLBACK_H */
globus_common_include.h
Include System Headers.
globus_module.h
Reference Counting Module Activation and Deactivation.
globus_time.h
Time Types and Macros.
globus_callback_func_t
void(* globus_callback_func_t)(void *user_arg)
Globus callback prototype.
Definition globus_callback.h:311
globus_callback_space_register_oneshot
globus_result_t globus_callback_space_register_oneshot(globus_callback_handle_t *callback_handle, const globus_reltime_t *delay_time, globus_callback_func_t callback_func, void *callback_user_arg, globus_callback_space_t space)
Register a oneshot some delay from now.
globus_callback_space_register_periodic
globus_result_t globus_callback_space_register_periodic(globus_callback_handle_t *callback_handle, const globus_reltime_t *delay_time, const globus_reltime_t *period, globus_callback_func_t callback_func, void *callback_user_arg, globus_callback_space_t space)
Register a periodic callback.
globus_callback_space_poll
void globus_callback_space_poll(const globus_abstime_t *timestop, globus_callback_space_t space)
Poll for ready callbacks.
globus_callback_adjust_oneshot
globus_result_t globus_callback_adjust_oneshot(globus_callback_handle_t callback_handle, const globus_reltime_t *new_delay)
Adjust the delay of a oneshot callback.
globus_callback_signal_poll
void globus_callback_signal_poll()
Signal the poll.
globus_callback_unregister
globus_result_t globus_callback_unregister(globus_callback_handle_t callback_handle, globus_callback_func_t unregister_callback, void *unreg_arg, globus_bool_t *active)
Unregister a callback.
globus_callback_adjust_period
globus_result_t globus_callback_adjust_period(globus_callback_handle_t callback_handle, const globus_reltime_t *new_period)
Adjust the period of a periodic callback.
globus_callback_has_time_expired
globus_bool_t globus_callback_has_time_expired()
See if there is remaining time in a callback.
globus_callback_add_wakeup_handler
void globus_callback_add_wakeup_handler(void(*wakeup)(void *), void *user_arg)
Register a wakeup handler with callback library.
globus_callback_unregister_signal_handler
globus_result_t globus_callback_unregister_signal_handler(int signum, globus_callback_func_t unregister_callback, void *unreg_arg)
Unregister a signal handling callback.
globus_callback_space_attr_get_behavior
globus_result_t globus_callback_space_attr_get_behavior(globus_callback_space_attr_t attr, globus_callback_space_behavior_t *behavior)
Get the behavior associated with an attr.
globus_callback_space_destroy
globus_result_t globus_callback_space_destroy(globus_callback_space_t space)
Destroy a reference to a user space.
globus_callback_space_get_depth
int globus_callback_space_get_depth(globus_callback_space_t space)
Retrieve the current nesting level of a space.
globus_callback_space_get
globus_result_t globus_callback_space_get(globus_callback_space_t *space)
Retrieve the space of a currently running callback.
globus_callback_space_init
globus_result_t globus_callback_space_init(globus_callback_space_t *space, globus_callback_space_attr_t attr)
Initialize a user space.
globus_callback_space_register_signal_handler
globus_result_t globus_callback_space_register_signal_handler(int signum, globus_bool_t persist, globus_callback_func_t callback_func, void *callback_user_arg, globus_callback_space_t space)
Fire a callback when the specified signal is received.
globus_callback_space_attr_destroy
globus_result_t globus_callback_space_attr_destroy(globus_callback_space_attr_t attr)
Destroy a space attr.
globus_callback_space_attr_set_behavior
globus_result_t globus_callback_space_attr_set_behavior(globus_callback_space_attr_t attr, globus_callback_space_behavior_t behavior)
Set the behavior of a space.
globus_callback_space_reference
globus_result_t globus_callback_space_reference(globus_callback_space_t space)
Take a reference to a space.
globus_callback_space_behavior_t
globus_callback_space_behavior_t
Callback space behaviors describe how a space behaves.
Definition globus_callback.h:721
globus_callback_space_attr_init
globus_result_t globus_callback_space_attr_init(globus_callback_space_attr_t *attr)
Initialize a space attr.
globus_callback_was_restarted
globus_bool_t globus_callback_was_restarted()
See if a callback has been restarted.
globus_callback_get_timeout
globus_bool_t globus_callback_get_timeout(globus_reltime_t *time_left)
Get the amount of time left in a callback.
globus_callback_space_is_single
globus_bool_t globus_callback_space_is_single(globus_callback_space_t space)
See if the specified space is a single threaded behavior space.
GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE
@ GLOBUS_CALLBACK_SPACE_BEHAVIOR_SINGLE
Definition globus_callback.h:725
GLOBUS_CALLBACK_SPACE_BEHAVIOR_SERIALIZED
@ GLOBUS_CALLBACK_SPACE_BEHAVIOR_SERIALIZED
Definition globus_callback.h:729
GLOBUS_CALLBACK_SPACE_BEHAVIOR_THREADED
@ GLOBUS_CALLBACK_SPACE_BEHAVIOR_THREADED
Definition globus_callback.h:731
globus_callback_space_t
int globus_callback_space_t
Callback space handle.
Definition globus_callback.h:112
globus_callback_handle_t
int globus_callback_handle_t
Periodic callback handle.
Definition globus_callback.h:102
globus_callback_error_type_t
globus_callback_error_type_t
Error types.
Definition globus_callback.h:79
globus_callback_space_attr_t
struct globus_l_callback_space_attr_s * globus_callback_space_attr_t
Callback space attribute.
Definition globus_callback.h:121
GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE
@ GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE
Definition globus_callback.h:81
GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC
@ GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC
Definition globus_callback.h:85
GLOBUS_CALLBACK_ERROR_NO_ACTIVE_CALLBACK
@ GLOBUS_CALLBACK_ERROR_NO_ACTIVE_CALLBACK
Definition globus_callback.h:91
GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED
@ GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED
Definition globus_callback.h:89
GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT
@ GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT
Definition globus_callback.h:87
GLOBUS_CALLBACK_ERROR_INVALID_SPACE
@ GLOBUS_CALLBACK_ERROR_INVALID_SPACE
Definition globus_callback.h:83
globus_result_t
uint32_t globus_result_t
Definition globus_types.h:99
globus_bool_t
int globus_bool_t
Boolean type.
Definition globus_types.h:93