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

類別:ThreadData

記憶體配置統一管理

類型 使用 成員 說明
建構子 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++定義

#if defined(WIN32) || defined(_WIN32)
typedef unsigned int (*ThreadFunction)(void * arg) ;
#else
typedef void *       (*ThreadFunction)(void * arg) ;
#endif

class ThreadData
{
  public:

    enum ThreadState {
      Idle     = 0   ,
      Active   = 1   ,
      Deactive = 2   ,
      Recycle  = 3 } ;

    int     Id          ;
    int     Type        ;
    int     Priority    ;
    int     Status      ;
    int     Running     ;
    int     StackSize   ;
    bool    Reservation ; // STACK_SIZE_PARAM_IS_A_RESERVATION ;
    char *  Arguments   ;
    void *  Extra       ;

    #if defined(WIN32) || defined(_WIN32)
    HANDLE         Thread              ;
    unsigned int   dwThreadID          ;
    #else
    pthread_t      Thread              ;
    #endif
    ThreadFunction Function            ;

    explicit  ThreadData  (void) ;
    virtual ~ ThreadData  (void) ;

    void      Start       (void) ;
    void      Stop        (void) ;
    void      Join        (void) ;

    int       setPriority (int priority) ;

    #if defined(WIN32) || defined(_WIN32)
    HANDLE    ThreadId    (void) ;
    #else
    pthread_t ThreadId    (void) ;
    #endif

    bool      isSelf      (void) ;

};


範例


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

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