45#include "MagickWand/studio.h"
46#include "MagickWand/MagickWand.h"
47#include "MagickWand/magick-wand-private.h"
48#include "MagickWand/wand.h"
51 *wand_ids = (SplayTreeInfo *) NULL;
53static MagickBooleanType
54 instantiate_wand = MagickFalse;
57 *wand_semaphore = (SemaphoreInfo *) NULL;
77WandExport
size_t AcquireWandId(
void)
85 if (wand_semaphore == (SemaphoreInfo *) NULL)
86 ActivateSemaphoreInfo(&wand_semaphore);
87 LockSemaphoreInfo(wand_semaphore);
88 if (wand_ids == (SplayTreeInfo *) NULL)
89 wand_ids=NewSplayTree((
int (*)(
const void *,
const void *)) NULL,
90 (
void *(*)(
void *)) NULL,(
void *(*)(
void *)) NULL);
92 (void) AddValueToSplayTree(wand_ids,(
const void *) wand_id,(
const void *)
94 instantiate_wand=MagickTrue;
95 UnlockSemaphoreInfo(wand_semaphore);
96 return((
size_t) wand_id);
119WandExport
void DestroyWandIds(
void)
121 if (wand_semaphore == (SemaphoreInfo *) NULL)
122 ActivateSemaphoreInfo(&wand_semaphore);
123 LockSemaphoreInfo(wand_semaphore);
124 if (wand_ids != (SplayTreeInfo *) NULL)
125 wand_ids=DestroySplayTree(wand_ids);
126 instantiate_wand=MagickFalse;
127 UnlockSemaphoreInfo(wand_semaphore);
128 RelinquishSemaphoreInfo(&wand_semaphore);
153WandExport
void RelinquishWandId(
const size_t id)
156 wand_id = (MagickAddressType)
id;
158 LockSemaphoreInfo(wand_semaphore);
159 if (wand_ids != (SplayTreeInfo *) NULL)
160 (void) DeleteNodeFromSplayTree(wand_ids,(
const void *) wand_id);
161 UnlockSemaphoreInfo(wand_semaphore);