wand.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "wand/studio.h"
00043 #include "wand/MagickWand.h"
00044 #include "wand/magick-wand-private.h"
00045 #include "wand/wand.h"
00046
00047 static SplayTreeInfo
00048 *wand_ids = (SplayTreeInfo *) NULL;
00049
00050 static MagickBooleanType
00051 instantiate_wand = MagickFalse;
00052
00053 static SemaphoreInfo
00054 *wand_semaphore = (SemaphoreInfo *) NULL;
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 WandExport unsigned long AcquireWandId(void)
00075 {
00076 static unsigned long
00077 id = 0;
00078
00079 if ((wand_ids == (SplayTreeInfo *) NULL) &&
00080 (instantiate_wand == MagickFalse))
00081 {
00082 AcquireSemaphoreInfo(&wand_semaphore);
00083 if ((wand_ids == (SplayTreeInfo *) NULL) &&
00084 (instantiate_wand == MagickFalse))
00085 {
00086 wand_ids=NewSplayTree((int (*)(const void *,const void *)) NULL,
00087 (void *(*)(void *)) NULL,(void *(*)(void *)) NULL);
00088 instantiate_wand=MagickTrue;
00089 }
00090 RelinquishSemaphoreInfo(wand_semaphore);
00091 }
00092 AcquireSemaphoreInfo(&wand_semaphore);
00093 id++;
00094 (void) AddValueToSplayTree(wand_ids,(const void *) id,(const void *) id);
00095 RelinquishSemaphoreInfo(wand_semaphore);
00096 return(id);
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 WandExport void RelinquishWandId(const unsigned long id)
00122 {
00123 (void) LogMagickEvent(WandEvent,GetMagickModule(),"...");
00124 if (wand_ids == (SplayTreeInfo *) NULL)
00125 return;
00126 AcquireSemaphoreInfo(&wand_semaphore);
00127 (void) DeleteNodeByValueFromSplayTree(wand_ids,(const void *) id);
00128 if ((instantiate_wand == MagickFalse) ||
00129 (GetNumberOfNodesInSplayTree(wand_ids) != 0))
00130 {
00131 RelinquishSemaphoreInfo(wand_semaphore);
00132 return;
00133 }
00134 wand_ids=DestroySplayTree(wand_ids);
00135 instantiate_wand=MagickFalse;
00136 RelinquishSemaphoreInfo(wand_semaphore);
00137 DestroySemaphoreInfo(&wand_semaphore);
00138 }