void*globus_priority_q_dequeue(globus_priority_q_t*priority_q)
Remove a Datum From A Priority Queue. The globus_priority_q_dequeue() function removes the highest-
priority datum from the given priority queue and returns it. If the priority_q pointer is NULL or the
priority queue is empty, this function returns NULL.
Parameterspriority_q Pointer to the priority queue to remove from.
Returns
This function returns the highest-priority datum from the priority queue.
intglobus_priority_q_destroy(globus_priority_q_t*priority_q)
Destroy a Priority Queue. The globus_priority_q_destroy() function destroys the contents of a priority
queue. After this function returns, the structure pointed to by priority_q is invalid and must not be
passed to any functions in the PriorityQueue module other globus_priority_q_init().
Note that this function does not call any destructors for the data inserted into the priority queue, so
the caller must be sure to either have other references to those data or free them before calling this
function.
Parameterspriority_q Pointer to the priority_q to destroy.
ReturnvaluesGLOBUS_SUCCESS Success
GLOBUS_FAILURE Failure
globus_bool_tglobus_priority_q_empty(globus_priority_q_t*priority_q)
Priority Queue Empty Predicate. The globus_priority_q_empty() function checks the given priority queue to
determine if it is empty. It is considered empty if it has been initialized via globus_priority_q_init()
and there are no items which have been inserted via globus_priority_q_enqueue() which have not been
removed by calling globus_priority_q_remove() or globus_priority_q_dequeue(). If it is empty, this
function returns GLOBUS_TRUE; otherwise it returns GLOBUS_FALSE.
Parameterspriority_q Pointer to the priority queue to check
ReturnvaluesGLOBUS_TRUE The priority queue is empty
GLOBUS_FALSE The priority queue is not empty, or the priority queue is invalid
intglobus_priority_q_enqueue(globus_priority_q_t*priority_q,void*datum,void*priority)
Add a Datum to a Priority Queue. The globus_priority_q_enqueue() function inserts a datum into the
priority queue based on its priority. When an item is inserted, the pointers to both the datum and the
priority are copied into the priority_q data structure, so neither may be freed until the datum is
removed from the priority queue, or undefined behavior may occur.
Note that there is no fifo fallback for priorities, so the order of two items with equivalent priorities
is not specified relative to each other. To enable fifo fallback, use a compound priority that includes a
priority level and a sequence number as the value pointed to by the priority parameter and pass a
suitable comparison function to initialize the priority queue.
Parameterspriority_q Pointer to the priority queue to insert datum into
datum The datum to insert into the queue
priority The priority of the datum
ReturnvaluesGLOBUS_SUCCESS Success
GLOBUS_FAILURE Failure
void*globus_priority_q_first(globus_priority_q_t*priority_q)
Get the Highest-Priority Datum From a Priority Queue. The globus_priority_q_first() function returns the
highest-priority datum from the priority queue pointed to by priority_q. The datum is not removed from
the queue; to do that, use globus_priority_q_dequeue() instead. If the priority_q pointer is NULL or the
queue is empty, this function returns NULL. The priority queue retains a reference to the returned datum,
so the pointer value returned must not freed until the datum is removed from the queue.
Parameterspriority_q Pointer to the priority queue to inspect
Returns
This function returns the highest-priority datum from the priority queue.
void*globus_priority_q_first_priority(globus_priority_q_t*priority_q)
Get the Highest Priority in Priority Queue. The globus_priority_q_first_priority() function returns the
value of highest priority in the priority queue (not the datum associated with that priority). If the
priority_q pointer is NULL or empty, this function returns NULL. The priority queue retains a reference
to the returned priority, so the pointer value returned must not be freed until the datum associated with
it is removed from the queue.
Parameterspriority_q Pointer to the priority queue to inspect
Returns
This function returns the highest priority value in the priority queue.
intglobus_priority_q_init(globus_priority_q_t*priority_q,globus_priority_q_cmp_func_tcmp_func)
Initialize a priority queue. The globus_priority_q_init() function initializes a globus_priority_q_t
structure for use with the other functions in the PriorityQueue module. If this function returns
GLOBUS_SUCCESS, the caller is responsible for deallocating the members of this structure when it is no
longer needed by passing it to globus_priority_q_destroy().
Parameterspriority_q Pointer to the priority queue structure to initialize.
cmp_func Pointer to a function which computes the relative relationship between two priorities. See
the documentation of globus_priority_q_cmp_func_t for details on how to implement that function.
ReturnvaluesGLOBUS_SUCCESS Success
GLOBUS_FAILURE Failure
void*globus_priority_q_modify(globus_priority_q_t*priority_q,void*datum,void*new_priority)
Modify the Priority of Datum. The globus_priority_q_modify() function modifies the priority of the
highest-priority instance of datum in the priority queue so that it new_priority. The old priority of the
datum is returned. If the priority_q is NULL or the datum is not present, this function returns NULL.
Parameterspriority_q Pointer to the priority queue to modify
datum Pointer to the datum whose priority is being modified
new_priority Pointer to the new priority
Returns
This function returns the old priority of datum.
void*globus_priority_q_remove(globus_priority_q_t*priority_q,void*datum)
Remove an Arbitrary Datum from a Priority Queue. The globus_priority_q_remove() function removes the
highest-priority instance of the specified datum from the priority queue and returns the datum if it is
found. If the priority_q is NULL or the datum is not found, this function returns NULL.
Parameterspriority_q Pointer to the priority queue to modify
datum Pointer to the datum to search for.
Returns
This function returns datum if it was present in the priority queue
intglobus_priority_q_size(globus_priority_q_t*priority_q)
Priority Queue Size. The globus_priority_q_size() function returns the size of the priority queue, that
is, the number of elements that are currently enqueued in it. The special value GLOBUS_FAILURE is
returned if a null pointer is passed to this function.
Parameterspriority_q Pointer to the priority queue to check
Returns
This function returns the number of elements in the queue, or GLOBUS_FAILURE if the priority_q
pointer is invalid.