gearmulator

Emulation of classic VA synths of the late 90s/2000s that are based on Motorola 56300 family DSPs
Log | Files | Refs | Submodules | README | LICENSE

pasync.cxx (867B)


      1 /*
      2  *
      3  *  C++ Portable Types Library (PTypes)
      4  *  Version 2.1.1  Released 27-Jun-2007
      5  *
      6  *  Copyright (C) 2001-2007 Hovik Melikyan
      7  *
      8  *  http://www.melikyan.com/ptypes/
      9  *
     10  */
     11 
     12 #ifdef WIN32
     13 #  include <windows.h>
     14 #else
     15 #  include <stdlib.h>
     16 #  include <unistd.h>
     17 #  include <pthread.h>
     18 #  ifdef __sun__
     19 #    include <poll.h>
     20 #  endif
     21 #endif
     22 
     23 #include "pasync.h"
     24 
     25 
     26 namespace ptypes {
     27 
     28 
     29 void ptdecl psleep(uint milliseconds)
     30 {
     31 #if defined(WIN32)
     32     Sleep(milliseconds);
     33 #elif defined(__sun__)
     34     poll(0, 0, milliseconds);
     35 #else
     36     usleep(milliseconds * 1000);
     37 #endif
     38 }
     39 
     40 
     41 pthread_id_t ptdecl pthrself() 
     42 {
     43 #ifdef WIN32
     44     return (int)GetCurrentThreadId();
     45 #else
     46     return pthread_self();
     47 #endif
     48 }
     49 
     50 
     51 bool ptdecl pthrequal(pthread_id_t id)
     52 {
     53 #ifdef WIN32
     54     return GetCurrentThreadId() == (uint)id;
     55 #else
     56     return pthread_equal(pthread_self(), id);
     57 #endif
     58 }
     59 
     60 
     61 }