13 #include <mrpt/config.h>    14 #if defined(MRPT_OS_APPLE)    20 #include <mach/mach_init.h>    21 #include <mach/task.h>    22 #include <mach/semaphore.h>    28 #include <semaphore.h>    29 #include <sys/timeb.h>    38 } sem_private_struct, *sem_private;
    41 CSemaphore::CSemaphore(
    42     unsigned int    initialCount,
    47         m_data.resize(
sizeof(semaphore_t));
    48         semaphore_t * sem = m_data.getAsPtr<semaphore_t>();
    50         kern_return_t 
error = semaphore_create(mach_task_self(), sem, SYNC_POLICY_FIFO, initialCount);
    51         if(
error != KERN_SUCCESS)
    58 CSemaphore::~CSemaphore()
    62   if (m_data.alias_count()==1)
    64         semaphore_t * sem = m_data.getAsPtr<semaphore_t>();
    65         semaphore_destroy(mach_task_self(), *sem);
    72 bool CSemaphore::waitForSignal( 
unsigned int timelimit )
    76         semaphore_t * sem = m_data.getAsPtr<semaphore_t>();
    80                 kern_return_t result = semaphore_wait(*sem);
    82                 return (result == KERN_SUCCESS);
    87                 ts.tv_sec = timelimit / 1000;
    88                 ts.tv_nsec = (timelimit % 1000) * 1000000;
    90                 kern_return_t result = semaphore_timedwait(*sem, ts);
    92                 return (result == KERN_SUCCESS);
    99 void CSemaphore::release(
unsigned int increaseCount )
   103         semaphore_t * sem = m_data.getAsPtr<semaphore_t>();
   104         for(
unsigned int i=0; i<increaseCount; ++i)
   106                 kern_return_t result = semaphore_signal(*sem);
   107                 if(result != KERN_SUCCESS)
   114 #endif // defined(MRPT_OS_APPLE) Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL. 
 
#define THROW_EXCEPTION(msg)
 
std::string BASE_IMPEXP format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf. 
 
This namespace provides multitask, synchronization utilities. 
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.