PMCONTEXTWALK(3)

NAME
__pmContextWalk - traversal of all PMAPI contexts

C SYNOPSIS
#include "pmapi.h"
#include "libpcp.h"

void (*__pmContextWalkCallback)(void *handle, __pmContext *ctxp);
int __pmContextWalk(void *handle, __pmContextWalkCallback callback,

cc ... -lpcp

CAVEAT
This documentation is intended for internal Performance Co-Pilot (PCP) developer use.

These interfaces are not part of the PCP APIs that are guaranteed to remain fixed across releases, and they may not work, or may provide different semantics at some point in the future.

DESCRIPTION
__pmContextWalk provides a thread-safe and lock-safe way of processing each active PMAPI context in turn.

For each valid PMAPI context, callback is called with handle passed in from the __pmContextWalk caller and ctxp pointing to a context for which the c_lock lock has been acquired. The handle argument is a pointer to an arbitrary object that may be shared between the __pmContextWalk caller and the callback routine, but is not otherwise accessed by __pmContextWalk, so could be NULL.

The per-context c_lock is released by __pmContextWalk after callback is called and should not be unlocked by callback.

For the duration of the call to __pmContextWalk all context initiation (via pmNewContext(3), pmDupContext (3) or pmReconnectContext(3)) and teardown (via pmDestroyContext(3)) is blocked.

RETURN VALUES
__pmContextWalk returns the number of contexts processed and hence the number of times callback was called, else a negative value suitable for reporting with pmErrStr(3).

SEE ALSO
PMAPI(3), pmDestroyContext(3), pmDupContext(3), pmErrStr(3), pmNewContext(3) and pmReconnectContext(3).