1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_ThreadLocalStorage.h 4 5 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 16743 $ 14 *---------------------------------------------------------------------------*/ 15 16 /*! @file 17 @brief スレッドローカルストレージ に関するAPI の宣言 18 19 :include nn/os.h 20 */ 21 #ifndef NN_OS_OS_THREADLOCALSTORAGE_H_ 22 #define NN_OS_OS_THREADLOCALSTORAGE_H_ 23 24 #include <nn/types.h> 25 26 #ifdef __cplusplus 27 28 namespace nn{ namespace os{ 29 30 /*! 31 @brief uptr と同じサイズを持つスレッドローカルストレージを表すクラスです。 32 33 スレッドローカルストレージは、一定数の uptr のスロットからなっており、 34 コンストラクタによってこのスロットを予約します。 35 予約に失敗した場合、アプリケーションは強制終了されます。 36 37 スレッドローカルストレージに格納されたデータの取得・設定は、 38 @ref GetValue と @ref SetValue で行うことができます。 39 40 スレッドは作成時に、全てのスレッドローカルストレージ領域を 0 に初期化します。 41 */ 42 class ThreadLocalStorage 43 { 44 public: 45 46 /*! 47 @brief スレッドローカルストレージオブジェクトを生成し、スロットを一つ確保します。 48 */ 49 ThreadLocalStorage(); 50 51 /*! 52 @brief スロットを開放し、スレッドローカルストレージオブジェクトを破棄します。 53 */ 54 ~ThreadLocalStorage(); 55 56 /*! 57 @brief スレッドローカルストレージに格納されている値を取得します。 58 59 @return スレッドローカルストレージに格納されている値 60 */ 61 uptr GetValue() const; 62 63 /*! 64 @brief スレッドローカルストレージに格納されている値を設定します。 65 66 @param[in] value スレッドローカルストレージに格納されている値 67 @return 無し。 68 */ 69 void SetValue(uptr value); 70 71 private: 72 73 s32 m_Index; //!< スロット番号 74 75 friend class Thread; 76 77 //!< 全スロットに格納されている値をクリアします。 78 static void ClearAllSlots(); 79 80 }; 81 82 }} // namespace nn::os 83 84 #endif // __cplusplus 85 86 /* NN_OS_OS_THREADLOCALSTORAGE_H_ */ 87 #endif /* NN_OS_OS_THREADLOCALSTORAGE_H_ */ 88