• 首頁
  • 文件
  • 下載
  • 狀態
  • 常見問題
  • 郵件列表
  • 應用程式
  • 外部鏈結
  • 版權
  • 志願者
  • 聯繫

類別:Mutex

記憶體配置統一管理

類型 使用 成員 說明
建構子 public Allocator(void)
解構子 public ~Allocator(void)
函式 public static void * allocate(long size) 配置記憶體。
函式 public static void free (void * block) 釋放記憶體。
函式 public static int blocks (void) 記憶體配置區塊數量。

建議

所有CIOS Audio Core內部的程式,都被建議使用Allocator來配置及釋放記憶體。

C++定義

class Mutex
{
  public:

    enum MutexType    {
      MutexDefault    ,
      MutexNormal     ,
      MutexErrorCheck ,
      MutexRecursive
    }                 ;

    explicit  Mutex        (void);
    virtual ~ Mutex        (void);

    void      setMutexType (MutexType MT);

    int       lock         (void);
    int       unlock       (void);
    int       locked       (void);
    int       tryLock      (void);

  protected:

    void      releaseMutex (void);

  private:

    #if defined(WIN32) || defined(_WIN32)
    CRITICAL_SECTION mutex  ;
    int              Locked ;
    #else
    pthread_mutex_t  mutex;
    #endif

};



範例


配置1024位元的記憶體。
char * buffer ;
buffer = (char *)Allocator::allocate(1024) ;

釋放記憶體。
Allocator::free(buffer) ;