This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

348
thread/SCRAPS.TXT Normal file
View File

@@ -0,0 +1,348 @@
WORD MessageQueue::waitMessage(ThreadMessage &someThreadMessage)
{
mNamedEvent.waitEvent(INFINITE,mIsAlertable);
// mNamedEvent.resetEvent();
mMutexSemaphore.requestMutex();
if(isQueueEmpty()){mMutexSemaphore.releaseMutex();mNamedEvent.resetEvent();return FALSE;}
getQueueMessage(someThreadMessage);
mMutexSemaphore.releaseMutex();
return TRUE;
}
WORD MessageQueue::getQueueMessage(ThreadMessage &someThreadMessage)
{
if(isQueueEmpty())return FALSE;
if(mMessageQueueHigh.size())
{
someThreadMessage=mMessageQueueHigh[0];
mMessageQueueHigh.remove(0L);
// someThreadMessage=mMessageQueueHigh[mMessageQueueHigh.size()-1];
// mMessageQueueHigh.remove(mMessageQueueHigh.size()-1);
}
else if(mMessageQueueNormal.size())
{
someThreadMessage=mMessageQueueNormal[0];
mMessageQueueNormal.remove(0L);
// someThreadMessage=mMessageQueueNormal[mMessageQueueNormal.size()-1];
// mMessageQueueNormal.remove(mMessageQueueNormal.size()-1);
}
else
{
someThreadMessage=mMessageQueueLow[0];
mMessageQueueLow.remove(0L);
// someThreadMessage=mMessageQueueLow[mMessageQueueLow.size()-1];
// mMessageQueueLow.remove(mMessageQueueLow.size()-1);
}
return TRUE;
}
WORD PureThread::start(LPVOID lpCreationData)
{
if(isOkay()||!mlpfnThreadProc)return FALSE;
mhThread=::CreateThread((SECURITY_ATTRIBUTES*)0,InitialStack,mlpfnThreadProc,lpCreationData,CREATE_SUSPENDED,&mThreadID);
mhThread=::
if(!mhThread)return FALSE;
mThreadStatus=InSuspend;
return TRUE;
}
unsigned long _beginthread( void( __cdecl *start_address )( void * ), unsigned stack_size, void *arglist );
unsigned long _beginthreadex( void *security, unsigned stack_size, unsigned ( __stdcall *start_address )( void * ), void *arglist, unsigned initflag, unsigned *thrdaddr );
Routine
Required Header
Optional Headers
Compatibility
_beginthread
<process.h>
Win<EFBFBD>95, Win<69>NT
_beginthreadex
<process.h>
Win<EFBFBD>95, Win<69>NT
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBCMT.LIB
Multithread static library, retail version
MSVCRT.LIB
Import library for MSVCRTx0.DLL, retail version
MSVCRTx0.DLL
Multithread DLL library, retail version
To use _beginthread or _beginthreadex, the application must link with one of the multithreaded C run-time libraries.
Return Value
If successful, each of these functions returns a handle to the newly created thread. _beginthread returns <20>1 on an error, in which case errno is set to EAGAIN if there are too many threads, or to EINVAL if the argument is invalid or the stack size is incorrect. _beginthreadex returns 0 on an error, in which case errno and doserrno are set.
Parameters
start_address Start address of routine that begins execution of new thread
stack_size Stack size for new thread or 0
arglist Argument list to be passed to new thread or NULL
security Security descriptor for new thread; must be NULL for Windows<77>95 applications
initflag Initial state of new thread (running or suspended)
thrdaddr Address of new thread
_CRTIMP unsigned long __cdecl _beginthreadex(void *, unsigned,
unsigned (__stdcall *) (void *), void *, unsigned, unsigned *);
inline
BOOL Event::isOkay(void)const
{
// return mhEvent?TRUE:FALSE;
return (mhEvent&&WAIT_TIMEOUT==::WaitForSingleObject(mhEvent,0));
}
WORD Event::waitEvent(DWORD timeOut,WORD alertable)const
{
DWORD waitResult;
// if(!mhEvent)return FALSE;
if(!isOkay())return FALSE;
waitResult=::WaitForSingleObjectEx(mhEvent,timeOut,alertable);
if(WAIT_ABANDONED==waitResult)return FALSE;
else if(WAIT_TIMEOUT==waitResult)return FALSE;
else if(WAIT_OBJECT_0==waitResult)return TRUE;
else return TRUE;
}
WORD Event::closeEvent(void)
{
// if(!mhEvent)return FALSE;
if(!isOkay())return FALSE;
::CloseHandle(mhEvent);
mhEvent=0;
return TRUE;
}
CallbackData::ReturnType TabPage::keyDownHandler(CallbackData &someCallbackData)
{
GlobalDefs::outDebug("TabPage::keyDownHandler");
KeyData keyData(someCallbackData);
if(keyData.controlKeyPressed()&&Home==keyData.virtualKey())
{
clearUpdate();
mCurrEntryIndex=0;
showCurrent();
}
else if(keyData.controlKeyPressed()&&End==keyData.virtualKey())
{
clearUpdate();
mCurrEntryIndex=mTabEntries.size()-1;
showCurrent();
}
else if(RightArrow==keyData.virtualKey())
{
if(mCurrEntryIndex+1<mTabEntries.size())
{
mCurrEntryIndex++;
clearUpdate();
showCurrent();
TabEntry &entry=mTabEntries[mCurrEntryIndex];
entry.play(mMIDIDevice->getDevice(),false);
}
else ::MessageBeep(0);
}
else if(LeftArrow==keyData.virtualKey())
{
if(mCurrEntryIndex-1>=0)
{
mCurrEntryIndex--;
clearUpdate();
showCurrent();
TabEntry &entry=mTabEntries[mCurrEntryIndex];
entry.play(mMIDIDevice->getDevice(),false);
}
else ::MessageBeep(0);
}
else if(DownArrow==keyData.virtualKey())
{
if(mCurrEntryIndex+mItemsPerTab+1>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
else mCurrEntryIndex+=(mItemsPerTab+1);
clearUpdate();
showCurrent();
TabEntry &entry=mTabEntries[mCurrEntryIndex];
entry.play(mMIDIDevice->getDevice(),false);
}
else if(UpArrow==keyData.virtualKey())
{
if(mCurrEntryIndex-(mItemsPerTab+1)<0)mCurrEntryIndex=0;
else mCurrEntryIndex-=(mItemsPerTab+1);
clearUpdate();
showCurrent();
TabEntry &entry=mTabEntries[mCurrEntryIndex];
entry.play(mMIDIDevice->getDevice(),false);
}
else if(!keyData.shiftKeyPressed()&&Delete==keyData.virtualKey())
{
cut();
}
else if(!keyData.shiftKeyPressed()&&Insert==keyData.virtualKey()) // insert after current position
{
Rect outlineRect;
TabEntry entry;
GDIPoint cursorPos;
clearUpdate();
if(!mTabEntries.size())
{
mTabEntries.insert(&entry);
mCurrEntryIndex=0;
}
else
{
mTabEntries.insertAfter(mCurrEntryIndex,&entry);
mCurrEntryIndex++;
}
if(!getFretEntry())
{
mTabEntries.remove(mCurrEntryIndex);
mCurrEntryIndex--; // smk
if(mCurrEntryIndex>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
}
getOutlineRect(mCurrEntryIndex,outlineRect);
mParent->clientToScreen(outlineRect);
cursorPos.x(outlineRect.left());
cursorPos.y(outlineRect.top());
::SetCursorPos(cursorPos.x(),cursorPos.y());
/* Rect outlineRect;
GDIPoint cursorPos;
::GetCursorPos(&cursorPos.getPOINT());
clearUpdate();
mTabEntries.insert(&TabEntry());
mCurrEntryIndex=mTabEntries.size()-1;
if(!getFretEntry())
{
mTabEntries.remove(mCurrEntryIndex);
if(mCurrEntryIndex>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
}
clearUpdate();
showCurrent();
getOutlineRect(mCurrEntryIndex,outlineRect);
mParent->clientToScreen(outlineRect);
cursorPos.x(outlineRect.left());
::SetCursorPos(cursorPos.x(),cursorPos.y()); */
}
else if(keyData.shiftKeyPressed()&&Insert==keyData.virtualKey()) // insert at end
{
Rect outlineRect;
GDIPoint cursorPos;
// ::GetCursorPos(&cursorPos.getPOINT());
clearUpdate();
mTabEntries.insert(&TabEntry());
mCurrEntryIndex=mTabEntries.size()-1;
if(!getFretEntry())
{
mCurrEntryIndex--;
mTabEntries.remove(mCurrEntryIndex);
if(mCurrEntryIndex>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
}
clearUpdate();
showCurrent();
getOutlineRect(mCurrEntryIndex,outlineRect);
mParent->clientToScreen(outlineRect);
cursorPos.x(outlineRect.left());
cursorPos.y(outlineRect.top());
::SetCursorPos(cursorPos.x(),cursorPos.y());
/* Rect outlineRect;
TabEntry entry;
GDIPoint cursorPos;
::GetCursorPos(&cursorPos.getPOINT());
clearUpdate();
if(!mTabEntries.size())
{
mTabEntries.insert(&entry);
mCurrEntryIndex=0;
}
else
{
mTabEntries.insertAfter(mCurrEntryIndex,&entry);
mCurrEntryIndex++;
}
if(!getFretEntry())
{
mTabEntries.remove(mCurrEntryIndex);
if(mCurrEntryIndex>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
}
getOutlineRect(mCurrEntryIndex,outlineRect);
mParent->clientToScreen(outlineRect);
cursorPos.x(outlineRect.left());
::SetCursorPos(cursorPos.x(),cursorPos.y()); */
}
GlobalDefs::outDebug(String("Key Code=")+String().fromInt(keyData.virtualKey()));
return false;
}
else if(keyData.shiftKeyPressed()&&Insert==keyData.virtualKey()) // insert at end
{
Rect outlineRect;
GDIPoint cursorPos;
// ::GetCursorPos(&cursorPos.getPOINT());
clearUpdate();
mTabEntries.insert(&TabEntry());
mCurrEntryIndex=mTabEntries.size()-1;
if(!getFretEntry())
{
mCurrEntryIndex--;
mTabEntries.remove(mCurrEntryIndex);
if(mCurrEntryIndex>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
}
clearUpdate();
showCurrent();
getOutlineRect(mCurrEntryIndex,outlineRect);
mParent->clientToScreen(outlineRect);
cursorPos.x(outlineRect.left());
cursorPos.y(outlineRect.top());
::SetCursorPos(cursorPos.x(),cursorPos.y());
/* Rect outlineRect;
TabEntry entry;
GDIPoint cursorPos;
::GetCursorPos(&cursorPos.getPOINT());
clearUpdate();
if(!mTabEntries.size())
{
mTabEntries.insert(&entry);
mCurrEntryIndex=0;
}
else
{
mTabEntries.insertAfter(mCurrEntryIndex,&entry);
mCurrEntryIndex++;
}
if(!getFretEntry())
{
mTabEntries.remove(mCurrEntryIndex);
if(mCurrEntryIndex>=mTabEntries.size())mCurrEntryIndex=mTabEntries.size()-1;
}
getOutlineRect(mCurrEntryIndex,outlineRect);
mParent->clientToScreen(outlineRect);
cursorPos.x(outlineRect.left());
::SetCursorPos(cursorPos.x(),cursorPos.y()); */
}