"Fossies" - the Fresh Open Source Software Archive

Member "bonnie++-2.00a/sync.cpp" (24 Dec 2008, 572 Bytes) of package /linux/privat/bonnie++-2.00a.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sync.cpp" see the Fossies "Dox" file reference documentation.

    1 #include "port.h"
    2 #include "semaphore.h"
    3 #include "sync.h"
    4 #include <stdio.h>
    5 
    6 Sync::Sync(SYNC_TYPE type, int semKey, int num_tests)
    7  : Semaphore(semKey, num_tests)
    8  , m_type(type)
    9 {
   10 }
   11 
   12 int Sync::decrement_and_wait(int nr_sem)
   13 {
   14   switch(m_type)
   15   {
   16   case eSem:
   17     return Semaphore::decrement_and_wait(nr_sem);
   18   case ePrompt:
   19     printf("\n%d:\n", nr_sem);
   20     fflush(NULL);
   21     char buf[16];
   22     fgets(buf, sizeof(buf) - 1, stdin);
   23   case eNone:
   24   break;
   25   }
   26   return 0;
   27 }
   28 
   29 int Sync::get_semid()
   30 {
   31   if(m_type == eSem)
   32     return Semaphore::get_semid();
   33   return 0;
   34 }