/* * /+\ * +\ Copyright 1995, 2000 Perforce Software. All rights reserved. * \+/ * * This file is part of Perforce - the FAST SCM System. */ #include <windows.h> #include <stdio.h> #include <winsvc.h> #include "ntthdlist.h" NtThreadList::NtThreadList() { head = 0; listSize = 0; InitializeCriticalSection( §ion ); } NtThreadList::~NtThreadList() { NtThreadEntry *entry; EnterCriticalSection( §ion ); while( ( entry = head ) ) { head = head->next; delete entry; } LeaveCriticalSection( §ion ); DeleteCriticalSection( §ion ); } void NtThreadList::AddThread( void *k, DWORD t ) { NtThreadEntry *entry = new NtThreadEntry(); entry->key = k; entry->tid = t; entry->prev = 0; EnterCriticalSection( §ion ); entry->next = head; if( head ) head->prev = entry; head = entry; listSize++; LeaveCriticalSection( §ion ); } int NtThreadList::RemoveThread( void *k ) { NtThreadEntry *entry; EnterCriticalSection( §ion ); entry = head; while( entry ) { if( entry->key == k ) { if( entry->next ) entry->next->prev = entry->prev; if( entry->prev ) entry->prev->next = entry->next; if( head == entry ) head = entry->next; break; } entry = entry->next; } listSize--; LeaveCriticalSection( §ion ); if( entry ) { delete entry; return 1; } return 0; } void NtThreadList::SuspendThreads() { NtThreadEntry *entry; HANDLE h; EnterCriticalSection( §ion ); entry = head; while( entry ) { h = OpenThread( THREAD_ALL_ACCESS, FALSE, entry->tid ); if( h != NULL ) { SuspendThread( h ); CloseHandle( h ); } entry = entry->next; } LeaveCriticalSection( §ion ); } #if 0 int NtThreadList::GetThread( DWORD *tid ) { NtThreadEntry *entry; EnterCriticalSection( §ion ); entry = head; if( entry ) { head = entry->next; if( head ) head->prev = 0; } LeaveCriticalSection( §ion ); if( entry ) { *tid = entry->tid; delete entry; return 1; } return 0; } #endif int NtThreadList::Empty() { int result; EnterCriticalSection( §ion ); result = head == 0; LeaveCriticalSection( §ion ); return result; } int NtThreadList::GetThreadCount() { int result; EnterCriticalSection( §ion ); result = listSize; LeaveCriticalSection( §ion ); return result; }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 18760 | rlranft |
Populate -o //guest/perforce_software/p4/... //guest/rlranft/p4/.... |
||
//guest/perforce_software/p4/2015-1/sys/ntthdlist.cc | |||||
#1 | 15903 | Matt Attaway | Everything should be happy now between the Workshop and the depot paths | ||
//guest/perforce_software/p4/2015_1/sys/ntthdlist.cc | |||||
#1 | 15901 | Matt Attaway | Clean up code to fit modern Workshop naming standards | ||
//guest/perforce_software/p4/2015.1/sys/ntthdlist.cc | |||||
#1 | 12190 | Matt Attaway | Initial drop of 2015.1 p4/p4api source |