Example #1
0
void HotQ::PosixSemaphore::Reset(int newInitialCount)
{
    DestroySemaphore(true); 
    InitializeSemaphore(newInitialCount);
}
Example #2
0
HotQ::PosixSemaphore::PosixSemaphore(const char * name, int initialCount)
: mSem(0), mIsOwner(false) 
{
    sprintf(mSemName, "%s", name); 
    InitializeSemaphore(initialCount);
}
Example #3
0
MagickExport void
InitializeMagick(const char *path)
{
  const char
    *p;

  /* NOTE: This routine sets up the path to the client which needs to
     be determined before almost anything else works right. This also
     includes logging!!! So we can't start logging until the path is
     actually saved. As soon as we know what the path is we make the
     same call to DefineClientSettings to set it up. Please make sure
     that this rule is followed in any future updates the this code!!!
  */
  if (MagickInitialized == InitInitialized)
    return;
  SPINLOCK_WAIT;
  MagickInitialized=InitInitialized;
  SPINLOCK_RELEASE;
  
#if defined(MSWINDOWS)
# if defined(_DEBUG) && !defined(__BORLANDC__)
  {
    int
      debug;
    
    debug=_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
    debug|=_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF |
      _CRTDBG_LEAK_CHECK_DF;
    // debug=_CrtSetDbgFlag(debug);
    // _ASSERTE(_CrtCheckMemory());
  }
# endif /* defined(_DEBUG) */
#endif /* defined(MSWINDOWS) */
  
  (void) setlocale(LC_ALL,"");
  (void) setlocale(LC_NUMERIC,"C");

  /* Initialize semaphores */
  InitializeSemaphore();

  /* Initialize logging */
  InitializeLogInfo();

  /* Seed the random number generator */
  srand(MagickRandNewSeed());

  /* Initialize our random number generator */
  InitializeMagickRandomGenerator();

  /*
    Set logging flags using the value of MAGICK_DEBUG if it is set in
    the environment.
  */
  if ((p=getenv("MAGICK_DEBUG")) != (const char *) NULL)
    (void) SetLogEventMask(p);

  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
			"Initialize Magick");

  /*
    Set the filesystem block size.
  */
  {
    size_t
      block_size=16384;
    
    if ((p=getenv("MAGICK_IOBUF_SIZE")) != (const char *) NULL)
      block_size = (size_t) MagickAtoL(p);
    
    MagickSetFileSystemBlockSize(block_size);
  }

  /*
    Establish the path, filename, and display name of the client app
  */
  InitializeMagickClientPathAndName(path);
  /*
    If the client name did not get setup for any reason, we take one
    last shot at it using the data the caller passed us.
  */
  if (GetClientName() == (const char *) NULL)
    DefineClientName(path);

  /*
    Adjust minimum coder class if requested.
  */
  if ((p=getenv("MAGICK_CODER_STABILITY")) != (const char *) NULL)
    {
      if (LocaleCompare(p,"UNSTABLE") == 0)
        MinimumCoderClass=UnstableCoderClass;
      else if (LocaleCompare(p,"STABLE") == 0)
        MinimumCoderClass=StableCoderClass;
      else if (LocaleCompare(p,"PRIMARY") == 0)
        MinimumCoderClass=PrimaryCoderClass;
    }

  InitializeMagickSignalHandlers(); /* Signal handlers */
  InitializeTemporaryFiles();       /* Temporary files */
  InitializeMagickResources();      /* Resources */
  InitializeMagickRegistry();       /* Image/blob registry */
  InitializeConstitute();           /* Constitute semaphore */
  InitializeMagickInfoList();       /* Coder registrations + modules */
  InitializeMagicInfo();            /* File format detection */
  InitializeTypeInfo();             /* Font information */
  InitializeDelegateInfo();         /* External delegate information */
  InitializeColorInfo();            /* Color database */
  MagickInitializeCommandInfo();    /* Command parser */

  /* Let's log the three important setting as we exit this routine */
  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
    "Path: \"%s\" Name: \"%s\" Filename: \"%s\"",
      GetClientPath(),GetClientName(),GetClientFilename());
}