diff options
Diffstat (limited to 'include/m_system.h')
-rw-r--r-- | include/m_system.h | 143 |
1 files changed, 0 insertions, 143 deletions
diff --git a/include/m_system.h b/include/m_system.h index e8c22a9124..4cc9105773 100644 --- a/include/m_system.h +++ b/include/m_system.h @@ -133,149 +133,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define MS_SYSTEM_REMOVEWAIT "Miranda/System/RemoveWait"
/*
-
- -- Thread Safety --
-
- Proper thread safe shutdown was implemented in 0.3.0.0 (2003/04/18)
- and not before, therefore it is improper that any MT plugins be used
- with earlier versions of Miranda (as hav0c will result)
-
- Note: This does not apply to MT plugins which included their own
- thread-safe shutdown routines.
-
- Shutdown thread safety works thusly:
-
- All new threads must call MS_SYSTEM_THREAD_PUSH and MS_SYSTEM_THREAD_POP
- when they return.
-
- Due to the nature of thread creation, it is illegal to assume
- just a call pair of MS_SYSTEM_THREAD_PUSH inside the thread will
- be enough -- the source thread may only return when the new child
- thread has actually executed MS_SYSTEM_THREAD_PUSH
-
- This is because a thread maybe in an undefined state at the point
- when the thread creation routine returns, thus Miranda may exit
- thinking it is safe to do so, because MS_SYSTEM_THREAD_PUSH was not
- called in time.
-
- See miranda.c for how this can be done using an event object
- which is signalled just after the MS_SYSTEM_THREAD_PUSH call is executed
- and so the source thread knows that the created thread is known to Miranda.
-
- -- What happens when Miranda exits --
-
- Miranda will firstly set an event object to signalled, this will
- make MS_SYSTEM_TERMINATED return TRUE, it will then fire ME_SYSTEM_PRESHUTDOWN
- at this point, no plugins or modules are unloaded.
-
- Miranda will then enumerate all active threads and queue an APC call
- to each thread, so any thread in an alertable state will become active,
- this functionailty may not be required by your threads: but if you use
- the Winsock2 event object system or Sleep() please use the alertable
- wait functions, so that the thread will 'wake up' when Miranda queues
- a message to it, SleepEx() will return WAIT_IO_COMPLETION if this happens.
-
- After all threads have been signalled, Miranda will spin on the unwind thread stack waiting
- for it to become empty, in this time, it will carry on processing thread
- switches, clearing it's own APC calls (used by NotifyEventHooks(), CallServiceSync())
-
- So a thread should be written in this kind of form:
-
- void mythread(void *arg)
- {
- // assume all thread pushing/popping is done by forkthread()
- int run=1;
- for (;run;)
- {
- Beep(4391, 500);
- SleepEx(1500, TRUE);
- if (Miranda_Terminated()) {
- Beep(5000, 150); run=0;
- } //if
- } //for
- }
-
- The above will make a nice Beep every 1.5 seconds and when the UI
- quits, it will make a lower beep and then return.
-
- As many copies of this thread maybe running, the creator does not need
- to worry about what to do with previous threads, as long as they're on the
- unwind stack.If there are any global resources (and they're mutex) you can free() them
- at Unload(), which will only be called, after all threads have returned.
-
- -- Summary --
-
- MS_SYSTEM_TERMINATED (will start returning TRUE)
- ME_SYSTEM_PRESHUTDOWN will be fired (The CList won't be visible at this point)
-
- All PROTOTYPE_PROTOCOL registered plugins will be sent ID_STATUS_OFFLINE
- automatically.
-
- All the threads will be notified via QueueUserAPC() and then Miranda
- will poll on the unwind thread queue until it is empty.
-
- ME_SYSTEM_SHUTDOWN will be fired, the database will be unloaded, the core
- will be unloaded -- Miranda will return.
-
-*/
-
-/* 0.5.2+
-wParam=function address
-lParam=function parameter
-
-registers a thread in the core and forks it
-
-*/
-
-#define MS_SYSTEM_FORK_THREAD "Miranda/Thread/Fork"
-
-/* 0.5.2+
-wParam=void* - thread owner object
-lParam=FORK_THREADEX_PARAMS*
-
-registers a thread in the core and forks it
-passes the extended parameters info and returns the thread id
-
-*/
-
-typedef struct
-{
- pThreadFuncEx pFunc;
- int iStackSize;
- void* arg;
- unsigned* threadID;
-}
- FORK_THREADEX_PARAMS;
-
-#define MS_SYSTEM_FORK_THREAD_EX "Miranda/Thread/ForkEx"
-
-/*
-wParam=0
-lParam=0
-
-Add a thread to the unwind wait stack that Miranda will poll on
-when it is tearing down modules.
-
-This must be called in the context of the thread that is to be pushed
-i.e. there are no args, it works out what thread is being called
-and gets itself a handle to the calling thread.
-
-*/
-#define MS_SYSTEM_THREAD_PUSH "Miranda/Thread/Push"
-
-/*
-wParam=0
-lParam=0
-
-Remove a thread from the unwind wait stack -- it is expected
-that the call be made in the context of the thread to be removed.
-
-Miranda will begin to tear down modules and plugins if/when the
-last thread from the unwind stack is removed.
-*/
-#define MS_SYSTEM_THREAD_POP "Miranda/Thread/Pop"
-
-/*
wParam=0
lParam=0
|