00001 /* MAXScript_TLS.h - main include for MAXScript Thread Local Storage 00002 * 00003 * Copyright (c) John Wainwright, 1996 00004 * 00005 * 00006 */ 00007 00008 #pragma once 00009 00010 #include "..\ScripterExport.h" 00011 #include "..\..\WindowsDefines.h" 00012 #include "..\..\maxtypes.h" 00013 #include "..\..\maxapi.h" 00014 00015 // forward declarations 00016 class Value; 00017 class CharStream; 00018 class Rollout; 00019 class MAXScriptException; 00020 class MSPlugin; 00021 class Struct; 00022 class MSZipPackage; 00023 class String; 00024 class Control; 00025 class StringStream; 00026 00027 /* thread-local storage struct decl & access macros */ 00028 00029 struct MAXScript_TLS 00030 { 00031 MAXScript_TLS* next; /* links... */ 00032 MAXScript_TLS* prev; 00033 HANDLE my_thread; /* thread that owns this TLS struct */ 00034 DWORD my_thread_id; 00035 00036 #undef def_thread_local 00037 #define def_thread_local(type, lcl, type_collectable, init_val) type lcl 00038 # include "..\protocols\thread_locals.inl" 00039 00040 }; 00041 00042 #define thread_local(x) (((MAXScript_TLS*)TlsGetValue(thread_locals_index))->x) 00043 00044 /* index, tls struct list globals */ 00045 00046 extern ScripterExport int thread_locals_index; 00047 extern int thread_id_index; 00048 extern MAXScript_TLS* MAXScript_TLS_list; 00049 00050 00051 inline void needs_redraw_set() 00052 { 00053 if (thread_local(redraw_mode) && thread_local(needs_redraw) == 0) 00054 thread_local(needs_redraw) = 1; 00055 } 00056 inline void needs_complete_redraw_set() 00057 { 00058 if thread_local(redraw_mode) 00059 thread_local(needs_redraw) = 2; 00060 } 00061 inline void needs_redraw_clear() 00062 { 00063 thread_local(needs_redraw) = 0; 00064 } 00065 00066 #define MAXScript_time() \ 00067 (thread_local(use_time_context) ? thread_local(current_time) : GetCOREInterface()->GetTime()) 00068 00069 void alloc_thread_locals(); 00070 ScripterExport void init_thread_locals(); 00071 void free_thread_locals(); 00072 void copy_thread_locals(MAXScript_TLS* source, MAXScript_TLS* target);