mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-08 22:15:21 +00:00
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:
parent
4221d64fcb
commit
114aa0751e
@ -36,10 +36,42 @@
|
||||
|
||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||
|
||||
struct _virObjectEventCallbackList {
|
||||
unsigned int nextID;
|
||||
size_t count;
|
||||
virObjectEventCallbackPtr *callbacks;
|
||||
};
|
||||
|
||||
struct _virObjectEventQueue {
|
||||
size_t count;
|
||||
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;
|
||||
|
||||
@ -267,7 +299,7 @@ virObjectEventCallbackLookup(virConnectPtr conn,
|
||||
*
|
||||
* Internal function to add a callback from a virObjectEventCallbackListPtr
|
||||
*/
|
||||
int
|
||||
static int
|
||||
virObjectEventCallbackListAddID(virConnectPtr conn,
|
||||
virObjectEventCallbackListPtr cbList,
|
||||
unsigned char uuid[VIR_UUID_BUFLEN],
|
||||
@ -374,7 +406,7 @@ virObjectEventCallbackListEventID(virConnectPtr conn,
|
||||
*
|
||||
* Removes all elements from the queue
|
||||
*/
|
||||
void
|
||||
static void
|
||||
virObjectEventQueueClear(virObjectEventQueuePtr queue)
|
||||
{
|
||||
size_t i;
|
||||
@ -420,7 +452,7 @@ virObjectEventQueueNew(void)
|
||||
*
|
||||
* Lock event state before calling functions from object_event_private.h.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
virObjectEventStateLock(virObjectEventStatePtr state)
|
||||
{
|
||||
virMutexLock(&state->lock);
|
||||
@ -433,7 +465,7 @@ virObjectEventStateLock(virObjectEventStatePtr state)
|
||||
*
|
||||
* Unlock event state after calling functions from object_event_private.h.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
virObjectEventStateUnlock(virObjectEventStatePtr state)
|
||||
{
|
||||
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
|
||||
* flush the callback queue.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
virObjectEventTimer(int timer ATTRIBUTE_UNUSED, void *opaque)
|
||||
{
|
||||
virObjectEventStatePtr state = opaque;
|
||||
|
@ -35,41 +35,9 @@ struct _virObjectMeta {
|
||||
typedef struct _virObjectMeta virObjectMeta;
|
||||
typedef virObjectMeta *virObjectMetaPtr;
|
||||
|
||||
struct _virObjectEventCallbackList {
|
||||
unsigned int nextID;
|
||||
size_t count;
|
||||
virObjectEventCallbackPtr *callbacks;
|
||||
};
|
||||
typedef struct _virObjectEventCallbackList virObjectEventCallbackList;
|
||||
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
|
||||
(*virObjectEventDispatchFunc)(virConnectPtr conn,
|
||||
virObjectEventPtr event,
|
||||
@ -95,32 +63,6 @@ virObjectEventStateCallbackID(virConnectPtr conn,
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
||||
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 *
|
||||
virObjectEventNew(virClassPtr klass,
|
||||
virObjectEventDispatchFunc dispatcher,
|
||||
|
Loading…
Reference in New Issue
Block a user