亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
欧洲av一区二区嗯嗯嗯啊| 日韩精品免费视频人成| 国产成人av影院| 久久久久成人黄色影片| 豆国产96在线|亚洲| 欧美国产激情二区三区| 99久久精品国产毛片| 亚洲与欧洲av电影| 欧美高清hd18日本| 蜜臂av日日欢夜夜爽一区| 久久综合九色综合久久久精品综合 | 国产日韩欧美精品一区| 成人黄色av网站在线| 亚洲欧美aⅴ...| 88在线观看91蜜桃国自产| 久久激情五月激情| 国产性做久久久久久| 91久久精品国产91性色tv| 日韩精品电影在线观看| 久久嫩草精品久久久久| 色一情一伦一子一伦一区| 亚洲国产成人tv| xf在线a精品一区二区视频网站| 成人黄色小视频| 亚洲3atv精品一区二区三区| 久久久久久久久久电影| 99re这里只有精品6| 免费成人性网站| 国产精品乱码人人做人人爱| 欧美在线制服丝袜| 国精品**一区二区三区在线蜜桃| 1000精品久久久久久久久| 在线播放亚洲一区| 国产白丝精品91爽爽久久| 亚洲狠狠爱一区二区三区| 久久这里只精品最新地址| 色婷婷激情久久| 国产揄拍国内精品对白| 亚洲一区二区免费视频| 中文av一区二区| 7777精品伊人久久久大香线蕉经典版下载 | 欧美福利视频一区| 99在线视频精品| 美国十次了思思久久精品导航| 久久精品免视看| 91精品国产一区二区三区香蕉 | 青青草精品视频| 一区二区在线免费观看| 久久影院电视剧免费观看| 欧美日韩在线不卡| 91亚洲资源网| 国产91综合一区在线观看| 日本成人超碰在线观看| 亚洲欧美视频在线观看| 久久影院午夜片一区| 91精品国产色综合久久不卡蜜臀 | 中文字幕色av一区二区三区| 精品国偷自产国产一区| 欧美另类高清zo欧美| 色国产综合视频| 色综合久久久久久久久久久| 国产乱国产乱300精品| 麻豆国产精品一区二区三区| 亚洲国产精品精华液网站| 国产精品对白交换视频| 国产女人aaa级久久久级 | 国产jizzjizz一区二区| 免费观看在线综合色| 午夜在线电影亚洲一区| 亚洲国产裸拍裸体视频在线观看乱了 | 日韩欧美亚洲国产另类| 欧美人与禽zozo性伦| 欧美三级资源在线| 欧美日韩视频在线一区二区| 欧美三区在线视频| 欧美日韩你懂得| 欧美一区午夜精品| 日韩色在线观看| 欧美mv日韩mv| 337p粉嫩大胆噜噜噜噜噜91av| 日韩一级成人av| 精品久久久久久久久久久久久久久久久 | 久久成人av少妇免费| 麻豆久久久久久久| 精品在线亚洲视频| 激情综合五月婷婷| 高清国产一区二区| av不卡在线观看| 91久久精品一区二区二区| 欧美午夜精品久久久久久孕妇| 日本丰满少妇一区二区三区| 在线影院国内精品| 欧美日韩精品免费| 精品久久人人做人人爱| 国产网红主播福利一区二区| 亚洲国产成人午夜在线一区| 国产精品久久久久影院老司| 亚洲欧美另类在线| 日精品一区二区三区| 麻豆成人91精品二区三区| 国产一区二区三区免费观看| 成人午夜视频在线观看| 色综合夜色一区| 欧美日韩一区不卡| 精品久久久久久久久久久久久久久久久 | 亚洲国产一区二区视频| 日韩 欧美一区二区三区| 国产综合成人久久大片91| 粗大黑人巨茎大战欧美成人| 色综合久久中文字幕综合网| 91精品啪在线观看国产60岁| 久久综合久久鬼色中文字| 亚洲婷婷综合色高清在线| 午夜视频一区二区三区| 韩国一区二区三区| 91久久精品一区二区| 精品国产在天天线2019| 一区二区中文视频| 久久激情五月婷婷| 色婷婷综合激情| 久久毛片高清国产| 亚洲成人一二三| 在线看国产日韩| 日韩视频在线观看一区二区| 国产精品成人免费| 全国精品久久少妇| 91色在线porny| 欧美精品一区二区三区视频| 亚洲免费在线电影| 国产精品资源网| 这里只有精品电影| 亚洲视频网在线直播| 狠狠色丁香久久婷婷综合_中| 一道本成人在线| 久久免费精品国产久精品久久久久| 亚洲人吸女人奶水| 国产成人aaaa| 欧美mv和日韩mv的网站| 亚洲综合色在线| 99久久国产综合精品色伊| 26uuu精品一区二区| 日韩精品一二三四| 色噜噜久久综合| 国产精品入口麻豆九色| 激情欧美日韩一区二区| 欧美日韩一区二区在线观看 | 91精品国产91综合久久蜜臀| 日韩码欧中文字| 国产成人高清视频| 久久综合狠狠综合| 久久av资源网| 欧美高清视频在线高清观看mv色露露十八| 亚洲国产精品v| 激情图片小说一区| 日韩午夜激情免费电影| 亚洲午夜国产一区99re久久| 99久久综合精品| 国产精品国产a| 成人av网址在线| 欧美国产欧美综合| 国产99久久久精品| 日本一区二区三区久久久久久久久不 | 欧美视频中文字幕| 亚洲日本一区二区| 99精品久久99久久久久| 国产精品高清亚洲| 99精品热视频| 亚洲蜜臀av乱码久久精品蜜桃| 成人一区二区三区| 国产精品久久久久aaaa樱花| 春色校园综合激情亚洲| 国产精品进线69影院| 99久久精品99国产精品| 亚洲精品国产a久久久久久| 色菇凉天天综合网| 亚洲第一激情av| 777午夜精品免费视频| 久久精品国产一区二区三| 精品国产一区二区三区av性色| 精品制服美女久久| 国产精品全国免费观看高清| a在线播放不卡| 亚洲综合色噜噜狠狠| 91.com视频| 国产成人精品在线看| 中文字幕一区二区三区在线观看| 一本一道综合狠狠老| 日日欢夜夜爽一区| 欧美精品一区二区三区蜜臀| 成人免费高清在线| 亚洲一级在线观看| 欧美成人一区二区三区| 国产精品自产自拍| 亚洲美女免费视频| 欧美日韩亚洲综合在线| 国产在线一区观看| 国产精品久久福利| 91精品国产综合久久久久久久 | 亚洲一区在线观看免费| 日韩女优制服丝袜电影|