event: tighten scope of object_event

Tighten up scope after the previous patch avoided using
internals.  This will also make it easier to change
internal implementation without having to chase down quite
as many impacted callers or worrying about two files getting
implementations out of sync.

* src/conf/object_event_private.h
(virObjectEventCallbackListAddID, virObjectEventQueueClear)
(virObjectEventStateLock, virObjectEventStateUnlock)
(virObjectEventTimer): Drop prototype.
(_virObjectEventCallbackList, _virObjectEventState)
(_virObjectEventCallback): Move...
* src/conf/object_event.c: ...here.
(virObjectEventCallbackListAddID, virObjectEventQueueClear)
(virObjectEventStateLock, virObjectEventStateUnlock)
(virObjectEventTimer): Mark private.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2014-01-03 14:44:29 -07:00
parent 4221d64fcb
commit 114aa0751e
2 changed files with 37 additions and 63 deletions

View File

@ -36,10 +36,42 @@
#define VIR_FROM_THIS VIR_FROM_NONE #define VIR_FROM_THIS VIR_FROM_NONE
struct _virObjectEventCallbackList {
unsigned int nextID;
size_t count;
virObjectEventCallbackPtr *callbacks;
};
struct _virObjectEventQueue { struct _virObjectEventQueue {
size_t count; size_t count;
virObjectEventPtr *events; virObjectEventPtr *events;
}; };
typedef struct _virObjectEventQueue virObjectEventQueue;
typedef virObjectEventQueue *virObjectEventQueuePtr;
struct _virObjectEventState {
/* The list of domain event callbacks */
virObjectEventCallbackListPtr callbacks;
/* The queue of object events */
virObjectEventQueuePtr queue;
/* Timer for flushing events queue */
int timer;
/* Flag if we're in process of dispatching */
bool isDispatching;
virMutex lock;
};
struct _virObjectEventCallback {
int callbackID;
virClassPtr klass;
int eventID;
virConnectPtr conn;
virObjectMetaPtr meta;
virConnectObjectEventGenericCallback cb;
void *opaque;
virFreeCallback freecb;
bool deleted;
};
static virClassPtr virObjectEventClass; static virClassPtr virObjectEventClass;
@ -267,7 +299,7 @@ virObjectEventCallbackLookup(virConnectPtr conn,
* *
* Internal function to add a callback from a virObjectEventCallbackListPtr * Internal function to add a callback from a virObjectEventCallbackListPtr
*/ */
int static int
virObjectEventCallbackListAddID(virConnectPtr conn, virObjectEventCallbackListAddID(virConnectPtr conn,
virObjectEventCallbackListPtr cbList, virObjectEventCallbackListPtr cbList,
unsigned char uuid[VIR_UUID_BUFLEN], unsigned char uuid[VIR_UUID_BUFLEN],
@ -374,7 +406,7 @@ virObjectEventCallbackListEventID(virConnectPtr conn,
* *
* Removes all elements from the queue * Removes all elements from the queue
*/ */
void static void
virObjectEventQueueClear(virObjectEventQueuePtr queue) virObjectEventQueueClear(virObjectEventQueuePtr queue)
{ {
size_t i; size_t i;
@ -420,7 +452,7 @@ virObjectEventQueueNew(void)
* *
* Lock event state before calling functions from object_event_private.h. * Lock event state before calling functions from object_event_private.h.
*/ */
void static void
virObjectEventStateLock(virObjectEventStatePtr state) virObjectEventStateLock(virObjectEventStatePtr state)
{ {
virMutexLock(&state->lock); virMutexLock(&state->lock);
@ -433,7 +465,7 @@ virObjectEventStateLock(virObjectEventStatePtr state)
* *
* Unlock event state after calling functions from object_event_private.h. * Unlock event state after calling functions from object_event_private.h.
*/ */
void static void
virObjectEventStateUnlock(virObjectEventStatePtr state) virObjectEventStateUnlock(virObjectEventStatePtr state)
{ {
virMutexUnlock(&state->lock); virMutexUnlock(&state->lock);
@ -475,7 +507,7 @@ static void virObjectEventStateFlush(virObjectEventStatePtr state);
* the callback of a periodic timer on the event loop, in order to * the callback of a periodic timer on the event loop, in order to
* flush the callback queue. * flush the callback queue.
*/ */
void static void
virObjectEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque) virObjectEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
{ {
virObjectEventStatePtr state = opaque; virObjectEventStatePtr state = opaque;

View File

@ -35,41 +35,9 @@ struct _virObjectMeta {
typedef struct _virObjectMeta virObjectMeta; typedef struct _virObjectMeta virObjectMeta;
typedef virObjectMeta *virObjectMetaPtr; typedef virObjectMeta *virObjectMetaPtr;
struct _virObjectEventCallbackList {
unsigned int nextID;
size_t count;
virObjectEventCallbackPtr *callbacks;
};
typedef struct _virObjectEventCallbackList virObjectEventCallbackList; typedef struct _virObjectEventCallbackList virObjectEventCallbackList;
typedef virObjectEventCallbackList *virObjectEventCallbackListPtr; typedef virObjectEventCallbackList *virObjectEventCallbackListPtr;
typedef struct _virObjectEventQueue virObjectEventQueue;
typedef virObjectEventQueue *virObjectEventQueuePtr;
struct _virObjectEventState {
/* The list of domain event callbacks */
virObjectEventCallbackListPtr callbacks;
/* The queue of object events */
virObjectEventQueuePtr queue;
/* Timer for flushing events queue */
int timer;
/* Flag if we're in process of dispatching */
bool isDispatching;
virMutex lock;
};
struct _virObjectEventCallback {
int callbackID;
virClassPtr klass;
int eventID;
virConnectPtr conn;
virObjectMetaPtr meta;
virConnectObjectEventGenericCallback cb;
void *opaque;
virFreeCallback freecb;
bool deleted;
};
typedef void typedef void
(*virObjectEventDispatchFunc)(virConnectPtr conn, (*virObjectEventDispatchFunc)(virConnectPtr conn,
virObjectEventPtr event, virObjectEventPtr event,
@ -95,32 +63,6 @@ virObjectEventStateCallbackID(virConnectPtr conn,
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
ATTRIBUTE_NONNULL(5); ATTRIBUTE_NONNULL(5);
int
virObjectEventCallbackListAddID(virConnectPtr conn,
virObjectEventCallbackListPtr cbList,
unsigned char *uuid,
const char *name,
int id,
virClassPtr klass,
int eventID,
virConnectObjectEventGenericCallback callback,
void *opaque,
virFreeCallback freecb,
int *callbackID);
void
virObjectEventQueueClear(virObjectEventQueuePtr queue);
void
virObjectEventStateLock(virObjectEventStatePtr state);
void
virObjectEventStateUnlock(virObjectEventStatePtr state);
void
virObjectEventTimer(int timer,
void *opaque);
void * void *
virObjectEventNew(virClassPtr klass, virObjectEventNew(virClassPtr klass,
virObjectEventDispatchFunc dispatcher, virObjectEventDispatchFunc dispatcher,