eudora-mac/threading.c

1 line
54 KiB
C
Raw Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* File: Threading.c Author: Clarence Wong <cwong@qualcomm.com> Date: February 1997 - ... Copyright (c) 1997 by QUALCOMM Incorporated Comments: - To switch threading off, #undef THREADING_ON in PreCompTwoPPC.pch - Threads can access all global variables (globals have inter-thread global scope by default) - Threads can also maintain "intra-thread global" variables via context switch procs. (the scope of the variable is global to one specific thread.) Check out the threadContextData and threadGlobals structs to see the intra-thread globals - Do not unload code segments that are referenced in the calling chain of any running or stopped thread - Out-Context switch procs must be manually called from the thread termination proc -- SEE END OF FILE FOR DESIGN OVERVIEW -- -- SEE END OF FILE FOR BUG LIST -- */ #define FILE_NUM 90 #ifdef THREADING_ON #define THREAD_STACK_SIZE (HaveOSX() ? 0 : 64 K) #if __profile__ #include <Profiler.h> #endif // #define DEBUG_THREAD #include "threading.h" #pragma segment Threads /* private data structures */ typedef struct prefChange_ { short pref; uLong persId; } prefChangeRec, *prefChangePtr; short gNumBackgroundThreads = 0; static ThreadID gMainThreadID = 0; static short gCriticalSection = 0; /* private functions */ static OSErr CopySettingsForThread (short sourceRefN, PersHandle sourcePerslist, short *destRefN, PersHandle *destPersList, PersHandle *destCurPers); static OSErr DeleteSettingsForThread (short *settingsRefN); static OSErr SaveSettingsToMainThread (threadDataHandle threadData); static OSErr InitThreadGlobals (threadGlobalsPtr *newThreadGlobals); static OSErr DisposeThreadGlobals (threadGlobalsPtr threadGlobals); int GetFCCs(MessHandle messH, CSpecHandle fccSpecs); // move to sendmail.c? #ifdef IMAP static OSErr NewXferMail(threadDataHandle *tData, Boolean check, Boolean send, Boolean manual,Boolean ae,XferFlags flags,IMAPTransferPtr imapInfo); #else static OSErr NewXferMail(threadDataHandle *tData, Boolean check, Boolean send, Boolean manual,Boolean ae,XferFlags flags); #endif pascal void *XferMailThread (void *threadParameter); pascal void ThreadSwitchProcIn (ThreadID threadBeingSwitched, void *switchProcParam); pascal void ThreadSwitchProcOut (ThreadID threadBeingSwitched, void *switchProcParam); pascal void ThreadTermination (ThreadID threadTerminated, void *terminationProcParam); #ifdef TASK_PROGRESS_ON #if