亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? pthread_alloc

?? 粗慥集成算法集合 ,并有詳細的文檔資料和測試數據處
??
?? 第 1 頁 / 共 2 頁
字號:
/*
 *
 * Copyright (c) 1994
 * Hewlett-Packard Company
 *
 * Copyright (c) 1996,1997
 * Silicon Graphics Computer Systems, Inc.
 *
 * Copyright (c) 1997
 * Moscow Center for SPARC Technology
 *
 * Copyright (c) 1999 
 * Boris Fomitchev
 *
 * This material is provided "as is", with absolutely no warranty expressed
 * or implied. Any use is at your own risk.
 *
 * Permission to use or copy this software for any purpose is hereby granted 
 * without fee, provided the above notices are retained on all copies.
 * Permission to modify the code and to distribute modified code is granted,
 * provided the above notices are retained, and a notice that the code was
 * modified is included with the above copyright notice.
 *
 */

#ifndef __SGI_STL_PTHREAD_ALLOC
#define __SGI_STL_PTHREAD_ALLOC

// Pthread-specific node allocator.
// This is similar to the default allocator, except that free-list
// information is kept separately for each thread, avoiding locking.
// This should be reasonably fast even in the presence of threads.
// The down side is that storage may not be well-utilized.
// It is not an error to allocate memory in thread A and deallocate
// it in thread B.  But this effectively transfers ownership of the memory,
// so that it can only be reallocated by thread B.  Thus this can effectively
// result in a storage leak if it's done on a regular basis.
// It can also result in frequent sharing of
// cache lines among processors, with potentially serious performance
// consequences.

#ifndef __SGI_STL_INTERNAL_ALLOC_H
#include <stl_alloc.h>
#endif
#ifndef __RESTRICT
#  define __RESTRICT
#endif

__STL_BEGIN_NAMESPACE

#define __STL_DATA_ALIGNMENT 8

union _Pthread_alloc_obj {
    union _Pthread_alloc_obj * __free_list_link;
    char __client_data[__STL_DATA_ALIGNMENT];    /* The client sees this.    */
};

// Pthread allocators don't appear to the client to have meaningful
// instances.  We do in fact need to associate some state with each
// thread.  That state is represented by
// _Pthread_alloc_per_thread_state<_Max_size>.

template<size_t _Max_size>
struct _Pthread_alloc_per_thread_state {
  typedef _Pthread_alloc_obj __obj;
  enum { _S_NFREELISTS = _Max_size/__STL_DATA_ALIGNMENT };
  _Pthread_alloc_obj* volatile __free_list[_S_NFREELISTS]; 
  _Pthread_alloc_per_thread_state<_Max_size> * __next; 
	// Free list link for list of available per thread structures.
  	// When one of these becomes available for reuse due to thread
	// termination, any objects in its free list remain associated
	// with it.  The whole structure may then be used by a newly
	// created thread.
  _Pthread_alloc_per_thread_state() : __next(0)
  {
    memset((void *)__free_list, 0, (size_t)_S_NFREELISTS * sizeof(__obj *));
  }
  // Returns an object of size __n, and possibly adds to size n free list.
  void *_M_refill(size_t __n);
};

// Pthread-specific allocator.
// The argument specifies the largest object size allocated from per-thread
// free lists.  Larger objects are allocated using malloc_alloc.
// Max_size must be a power of 2.
template <size_t _Max_size = 128>
class _Pthread_alloc_template {

public: // but only for internal use:

  typedef _Pthread_alloc_obj __obj;

  // Allocates a chunk for nobjs of size size.  nobjs may be reduced
  // if it is inconvenient to allocate the requested number.
  static char *_S_chunk_alloc(size_t __size, int &__nobjs);

  enum {_S_ALIGN = __STL_DATA_ALIGNMENT};

  static size_t _S_round_up(size_t __bytes) {
        return (((__bytes) + (int)_S_ALIGN-1) & ~((int)_S_ALIGN - 1));
  }
  static size_t _S_freelist_index(size_t __bytes) {
        return (((__bytes) + (int)_S_ALIGN-1)/(int)_S_ALIGN - 1);
  }

private:
  // Chunk allocation state. And other shared state.
  // Protected by _S_chunk_allocator_lock.
  static pthread_mutex_t _S_chunk_allocator_lock;
  static char *_S_start_free;
  static char *_S_end_free;
  static size_t _S_heap_size;
  static _Pthread_alloc_per_thread_state<_Max_size>* _S_free_per_thread_states;
  static pthread_key_t _S_key;
  static bool _S_key_initialized;
        // Pthread key under which per thread state is stored. 
        // Allocator instances that are currently unclaimed by any thread.
  static void _S_destructor(void *instance);
        // Function to be called on thread exit to reclaim per thread
        // state.
  static _Pthread_alloc_per_thread_state<_Max_size> *_S_new_per_thread_state();
        // Return a recycled or new per thread state.
  static _Pthread_alloc_per_thread_state<_Max_size> *_S_get_per_thread_state();
        // ensure that the current thread has an associated
        // per thread state.
  class _M_lock;
  friend class _M_lock;
  class _M_lock {
      public:
        _M_lock () { pthread_mutex_lock(&_S_chunk_allocator_lock); }
        ~_M_lock () { pthread_mutex_unlock(&_S_chunk_allocator_lock); }
  };

public:

  /* n must be > 0      */
  static void * allocate(size_t __n)
  {
    __obj * volatile * __my_free_list;
    __obj * __RESTRICT __result;
    _Pthread_alloc_per_thread_state<_Max_size>* __a;

    if (__n > _Max_size) {
        return(__malloc_alloc<0>::allocate(__n));
    }
    if (!_S_key_initialized ||
        !(__a = (_Pthread_alloc_per_thread_state<_Max_size>*)
                                 pthread_getspecific(_S_key))) {
        __a = _S_get_per_thread_state();
    }
    __my_free_list = __a -> __free_list + _S_freelist_index(__n);
    __result = *__my_free_list;
    if (__result == 0) {
        void *__r = __a -> _M_refill(_S_round_up(__n));
        return __r;
    }
    *__my_free_list = __result -> __free_list_link;
    return (__result);
  };

  /* p may not be 0 */
  static void deallocate(void *__p, size_t __n)
  {
    __obj *__q = (__obj *)__p;
    __obj * volatile * __my_free_list;
    _Pthread_alloc_per_thread_state<_Max_size>* __a;

    if (__n > _Max_size) {
        __malloc_alloc<0>::deallocate(__p, __n);
        return;
    }
    if (!_S_key_initialized ||
        !(__a = (_Pthread_alloc_per_thread_state<_Max_size> *)
                pthread_getspecific(_S_key))) {
        __a = _S_get_per_thread_state();
    }
    __my_free_list = __a->__free_list + _S_freelist_index(__n);
    __q -> __free_list_link = *__my_free_list;
    *__my_free_list = __q;
  }

  static void * reallocate(void *__p, size_t __old_sz, size_t __new_sz);

} ;

typedef _Pthread_alloc_template<> pthread_alloc;


template <size_t _Max_size>
void _Pthread_alloc_template<_Max_size>::_S_destructor(void * __instance)
{
    _M_lock __lock_instance;	// Need to acquire lock here.
    _Pthread_alloc_per_thread_state<_Max_size>* __s =
        (_Pthread_alloc_per_thread_state<_Max_size> *)__instance;
    __s -> __next = _S_free_per_thread_states;
    _S_free_per_thread_states = __s;
}

template <size_t _Max_size>
_Pthread_alloc_per_thread_state<_Max_size> *
_Pthread_alloc_template<_Max_size>::_S_new_per_thread_state()
{    
    /* lock already held here.	*/
    if (0 != _S_free_per_thread_states) {
        _Pthread_alloc_per_thread_state<_Max_size> *__result =
					_S_free_per_thread_states;
        _S_free_per_thread_states = _S_free_per_thread_states -> __next;
        return __result;
    } else {
        return __STL_NEW _Pthread_alloc_per_thread_state<_Max_size>;
    }
}

template <size_t _Max_size>
_Pthread_alloc_per_thread_state<_Max_size> *
_Pthread_alloc_template<_Max_size>::_S_get_per_thread_state()
{
    /*REFERENCED*/
    _M_lock __lock_instance;	// Need to acquire lock here.
    int __ret_code;
    _Pthread_alloc_per_thread_state<_Max_size> * __result;
    if (!_S_key_initialized) {
        if (pthread_key_create(&_S_key, _S_destructor)) {
            __THROW_BAD_ALLOC;  // failed
        }
        _S_key_initialized = true;
    }
    __result = _S_new_per_thread_state();
    __ret_code = pthread_setspecific(_S_key, __result);
    if (__ret_code) {
      if (__ret_code == ENOMEM) {
	__THROW_BAD_ALLOC;
      } else {
	// EINVAL
	abort();
      }
    }
    return __result;
}

/* We allocate memory in large chunks in order to avoid fragmenting     */
/* the malloc heap too much.                                            */
/* We assume that size is properly aligned.                             */
template <size_t _Max_size>
char *_Pthread_alloc_template<_Max_size>
::_S_chunk_alloc(size_t __p_size, int &__nobjs)
{
  {
    char * __result;
    size_t __total_bytes;
    size_t __bytes_left;
    /*REFERENCED*/
    _M_lock __lock_instance;         // Acquire lock for this routine

    __total_bytes = __p_size * __nobjs;
    __bytes_left = _S_end_free - _S_start_free;
    if (__bytes_left >= __total_bytes) {
        __result = _S_start_free;
        _S_start_free += __total_bytes;
        return(__result);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一区视频在线| 91丨九色丨黑人外教| 国产不卡视频一区| 欧美精品v国产精品v日韩精品| 中文字幕av一区二区三区高| 日本vs亚洲vs韩国一区三区二区| 91麻豆免费在线观看| 欧美精品一区二区三区高清aⅴ| 一区二区三区在线免费播放| 国产成人在线免费观看| 欧美一区二区三区色| 亚洲综合在线视频| 成人av在线网| 久久精品一区四区| 蜜桃av一区二区在线观看| 在线亚洲高清视频| 中文字幕中文字幕一区二区 | 日韩精品一区二区三区视频 | 成人影视亚洲图片在线| 日韩美女一区二区三区四区| 亚洲第一福利一区| 欧美性xxxxx极品少妇| 亚洲精品视频在线| 色综合久久久久综合| **欧美大码日韩| 99久久婷婷国产综合精品电影| 久久精品无码一区二区三区| 国产精品99久久久久久久女警| 久久午夜国产精品| 狠狠色丁香久久婷婷综合丁香| 欧美电影免费观看高清完整版| 美女被吸乳得到大胸91| 欧美成人性战久久| 国内精品国产成人| 欧美国产亚洲另类动漫| 成人在线视频一区| 综合av第一页| 在线免费一区三区| 午夜电影网亚洲视频| 欧美顶级少妇做爰| 美国精品在线观看| 国产日韩欧美亚洲| 99国产精品久久久| 亚洲成人动漫一区| 亚洲精品在线观看视频| 成人激情动漫在线观看| 亚洲精品综合在线| 在线成人av网站| 黄色小说综合网站| 国产精品乱码人人做人人爱 | 中文字幕不卡三区| 色噜噜狠狠成人网p站| 亚洲成人免费影院| 久久先锋影音av鲁色资源| 99re这里只有精品6| 亚洲图片欧美综合| 欧美videossexotv100| 粉嫩绯色av一区二区在线观看| 亚洲免费观看在线视频| 欧美肥妇bbw| 成人午夜激情视频| 亚洲在线观看免费视频| 精品毛片乱码1区2区3区| 成人高清免费在线播放| 肉肉av福利一精品导航| 中文天堂在线一区| 91精品婷婷国产综合久久| 成人激情小说乱人伦| 视频一区二区国产| 国产精品免费丝袜| 精品欧美一区二区三区精品久久| 97久久精品人人做人人爽| 看片网站欧美日韩| 樱桃视频在线观看一区| 久久久精品蜜桃| 欧美电影一区二区| 麻豆精品在线播放| 中文字幕精品一区二区精品绿巨人| 99久久精品一区| 麻豆视频观看网址久久| 亚洲一区视频在线观看视频| 久久久亚洲精品一区二区三区| 欧美日韩一区小说| www.欧美色图| 国产精品一二三区在线| 日本中文在线一区| 亚洲主播在线观看| 1区2区3区国产精品| 国产日韩亚洲欧美综合| 日韩午夜激情电影| 色婷婷精品久久二区二区蜜臂av| 久久9热精品视频| 亚洲高清视频中文字幕| 中文字幕日韩一区| 亚洲国产电影在线观看| 欧美精品一区二| 日韩欧美一区二区免费| 91精品国产一区二区三区香蕉| 色婷婷av久久久久久久| 国产视频亚洲色图| 日韩欧美aaaaaa| 91精品国产手机| 欧美浪妇xxxx高跟鞋交| 欧美中文字幕不卡| 在线观看一区日韩| 色综合久久中文综合久久牛| bt7086福利一区国产| 波多野结衣中文字幕一区二区三区| 紧缚奴在线一区二区三区| 另类小说综合欧美亚洲| 久久国产精品72免费观看| 青青草国产成人av片免费| 首页综合国产亚洲丝袜| 亚洲一区二区五区| 日韩和欧美一区二区三区| 日日欢夜夜爽一区| 老司机精品视频导航| 黄色成人免费在线| 成人美女视频在线观看| 99视频精品在线| 91在线观看视频| 在线免费不卡视频| 欧美日产国产精品| 精品国内二区三区| 久久久久久久久蜜桃| 国产精品无遮挡| 伊人婷婷欧美激情| 日本不卡123| 国产成人午夜精品5599| 91小视频在线免费看| 欧美视频一区二区三区四区| 日韩午夜精品电影| 国产欧美va欧美不卡在线| 国产精品美日韩| 亚洲一区二区精品3399| 青娱乐精品视频| 豆国产96在线|亚洲| 色噜噜狠狠色综合中国| 日韩一区二区精品在线观看| 国产三级欧美三级日产三级99| 自拍视频在线观看一区二区| 亚洲一区二区三区精品在线| 狠狠色2019综合网| 91在线丨porny丨国产| 欧美一区二区在线播放| 久久精品欧美日韩| 亚洲制服丝袜一区| 韩国视频一区二区| 91福利社在线观看| 日韩精品一区在线观看| 亚洲日本免费电影| 人禽交欧美网站| 91亚洲男人天堂| 日韩视频一区二区在线观看| 中文字幕一区二区三区蜜月| 琪琪一区二区三区| 一本大道久久精品懂色aⅴ | 成人av免费在线观看| 欧美二区三区91| 中文字幕人成不卡一区| 美女国产一区二区三区| 色网综合在线观看| 国产亚洲欧美日韩在线一区| 天天av天天翘天天综合网色鬼国产| 成人免费视频视频在线观看免费| 欧美精品123区| 亚洲乱码日产精品bd| 国产成人综合网站| 91精品国产综合久久福利软件 | 欧美一区二区免费| 亚洲另类在线制服丝袜| 国产不卡视频在线播放| 精品国产凹凸成av人导航| 午夜影视日本亚洲欧洲精品| gogogo免费视频观看亚洲一| 日韩视频免费观看高清完整版 | 亚洲美女视频一区| 国产福利不卡视频| 精品成人免费观看| 免费一级片91| 欧美日韩成人综合| 亚洲国产一区二区视频| 日本韩国精品在线| 亚洲嫩草精品久久| 成人亚洲精品久久久久软件| 久久久综合精品| 国产一区二区三区在线看麻豆| 7777精品伊人久久久大香线蕉超级流畅| 亚洲人成网站色在线观看| 99这里都是精品| 1000部国产精品成人观看| 成人app下载| 1024国产精品| 91国产成人在线| 亚洲综合色丁香婷婷六月图片| 日本高清不卡在线观看| 亚洲一区二区在线免费看| 欧美无乱码久久久免费午夜一区| 亚洲午夜精品网| 欧美日韩成人高清|