HANDLE StartThread(void *SecurityAttributes, DWORD StackSize, void *Parameter, DWORD CreationFlags, TThreadID &ThreadId) { return BeginThread(SecurityAttributes, StackSize, Parameter, CreationFlags, ThreadId); }
//--------------------------------------------------------------------------- int __fastcall StartThread(void * SecurityAttributes, unsigned int StackSize, void * Parameter, unsigned int CreationFlags, DWORD & ThreadId) { return BeginThread(SecurityAttributes, StackSize, Parameter, CreationFlags, ThreadId); }
void CLibraryTipCtrl::OnShow() { OnHide(); // Do the old image destroy BeginThread( "CtrlLibraryTip" ); Wakeup(); }
void OverlappedCall::Init() { HARDASSERT(::GetCurrentThreadId() == Interpreter::MainThreadId()); m_hEvtGo = NewAutoResetEvent(); m_hEvtCompleted = NewAutoResetEvent(); BeginThread(); }
void CDownloadTask::Copy() { Construct( dtaskCopy ); m_sDestination = DownloadGroups.GetCompletedPath( m_pDownload ).TrimRight( L"\\" ); VERIFY( BeginThread( "Download Task : Copy" ) ); // RunCopy() }
/****************************************************************************** * Public functions *****************************************************************************/ error_code threadlib_beginthread (THREAD_HANDLE *thread, void (*callback)(void *), void* arg) { BeginThread (thread->thread_handle, callback, arg); //if (thread->thread_handle == NULL) // don't feel like porting this // return SR_ERROR_CANT_CREATE_THREAD; return SR_SUCCESS; }
int Transfer::Start() { _tfm = new TfMethod(Transfer::tfm_static_join, Transfer::tfm_static_base, Transfer::tfm_static_multicast, Transfer::tfm_static_unicast, this); if(BeginThread() != 0) { LOG(LEVEL_ERROR, "Begin Thread Failed"); return -1; } return 0l; }
void CDownloadTask::MergeFile(LPCTSTR szPath, BOOL bValidation, const Fragments::List* pGaps) { Construct( dtaskMergeFile ); m_oMergeFiles.AddTail( (CString)szPath ); if ( pGaps ) m_oMergeGaps = *pGaps; m_bMergeValidation = bValidation; VERIFY( BeginThread( "Download Task : Merge" ) ); // RunMerge() }
void CListLoader::AddList(CSecureRule* pRule) { ASSERT( pRule->m_nType == CSecureRule::srExternal ); if ( ! pRule || pRule->m_nType != CSecureRule::srExternal || ! pRule->m_pContent ) return; if ( ! m_pQueue.Find( pRule ) ) m_pQueue.AddTail( pRule ); if ( ! IsThreadEnabled() ) BeginThread( "ListLoader" ); }
ComIO::ComIO() { ComIndex = 6; hCom = NULL; TaskMark = 0; Te.Create(0, 0, 200); We.Create(0); Re.Create(0); Rp = 0; BeginThread(); }
void CDownloadTask::PreviewRequest(LPCTSTR szURL) { Construct( dtaskPreviewRequest ); m_pRequest.Attach( new CHttpRequest() ); if ( ! m_pRequest ) return; // Out of memory m_pRequest->SetURL( szURL ); m_pRequest->AddHeader( L"Accept", L"image/jpeg" ); m_pRequest->LimitContentLength( Settings.Search.MaxPreviewLength ); VERIFY( BeginThread( "Download Task : Preview" ) ); // RunPreviewRequest() }
BOOL CBitprintsDownloader::Start(CBitprintsDownloadDlg* pDlg) { if ( m_hInternet ) return FALSE; m_hInternet = CNetwork::SafeInternetOpen(); if ( ! m_hInternet ) return FALSE; m_hSession = NULL; m_hRequest = NULL; m_pDlg = pDlg; m_bFinished = FALSE; m_nDelay = 0; m_nFailures = 0; BeginThread( "BitprintsDownloader" ); return TRUE; }
extern int __CBeginThread( thread_fn *start_addr, void *stack_bottom, unsigned stack_size, void *arglist ) { begin_thread_data data; data.start_addr = start_addr; data.stack_bottom = stack_bottom; data.arglist = arglist; data.semaphore = OpenLocalSemaphore( 0 ); if( BeginThread( &begin_thread_helper, stack_bottom, stack_size, &data ) != -1 ) { WaitOnLocalSemaphore( data.semaphore ); } else { data.tid = -1; } CloseLocalSemaphore( data.semaphore ); return( data.tid ); }
////////////////////////////////////////////////////////////////////// // CShareMonkeyData start BOOL CShareMonkeyData::Start(CLibraryFileView* pView, DWORD nFileIndex) { if ( m_hInternet ) return FALSE; CString strAgent = Settings.SmartAgent(); m_hInternet = InternetOpen( strAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 ); if ( ! m_hInternet ) return FALSE; m_hSession = NULL; m_hRequest = NULL; m_nDelay = 0; m_nFailures = 0; m_pFileView = pView; m_nFileIndex = nFileIndex; return BeginThread( "ShareMonkeyData" ); }
IUnknown* CPlugins::GetPlugin(LPCTSTR pszGroup, LPCTSTR pszType) { CLSID pCLSID; if ( ! LookupCLSID( pszGroup, pszType, pCLSID ) ) return NULL; // Disabled HRESULT hr; for ( int i = 0 ; ; ++i ) { { CSingleLock oLock( &m_pSection, FALSE ); if ( ! oLock.Lock( 500 ) ) return NULL; CComPtr< IUnknown > pPlugin; CPluginPtr* pGITPlugin = NULL; if ( m_pCache.Lookup( pCLSID, pGITPlugin ) ) { if ( ! pGITPlugin ) return NULL; if ( SUCCEEDED( hr = pGITPlugin->m_pGIT.CopyTo( &pPlugin ) ) ) return pPlugin.Detach(); TRACE( "Invalid plugin \"%s\"-\"%s\" %s\n", (LPCSTR)CT2A( pszGroup ), (LPCSTR)CT2A( pszType ), (LPCSTR)CT2A( Hashes::toGuid( pCLSID ) ) ); } if ( i == 1 ) break; m_inCLSID = pCLSID; // Create new one if ( ! BeginThread( "PluginCache" ) ) break; // Something really bad } Wakeup(); // Start process WaitForSingleObject( m_pReady, INFINITE ); // Wait for result } return NULL; }
// ------------------------------------------------------------------------------------------------------------------------------------------------------- APP_MAIN WinMain( APP_ARGS ) { gMainApp.SetDefault(); if (!gMainApp.Initialize(APP_ARGS_PUSH)) return FALSE; RFile.SetInfo(); BeginThread(MainTask, NULL, NULL); MCfg.Initialize(); if(gDataBase.Initialize() == true) { for ( int i = 1; i < MAX_SRV_TYPES; i++ ) { gMainApp.StartServer(i); } CLog.Info("Network Connection Successfully Initialized."); } return gMainApp.MsgLoop(); }
BOOL CPlugins::ReloadPlugin(LPCTSTR pszGroup, LPCTSTR pszType) { CLSID pCLSID; if ( ! LookupCLSID( pszGroup, pszType, pCLSID ) ) return FALSE; // Disabled { CQuickLock oLock( m_pSection ); m_inCLSID = pCLSID; // Create new one if ( ! BeginThread( "PluginCache" ) ) return FALSE; // Something really bad } Wakeup(); // Start process WaitForSingleObject( m_pReady, INFINITE ); // Wait for result return TRUE; }
// Start the job, locking down the program while it runs void JobStart() { sectionitem section; // Change the stage if (Job.stage != JobStageBefore) return; // Can only start when before Job.stage = JobStageRunning; // Record the time now as when the job starts Job.time = GetTickCount(); // Save tasks text from the tasks box to the registry Job.tasks = WindowTextGet(Handle.tasks); RegistryWrite(REGISTRYKEY, REGISTRYPATH, REGISTRYNAME, Job.tasks); // Delete the log file from last time and open a new one string s = LogPath(L"Backup"); DiskDeleteFile(s); Job.log = LogOpen(s, L"Errors"); // Start a new thread that will perform all the tasks BeginThread(Tasks); // Have the thread run the Tasks() function }
void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx) { SSL_CTX *ssl_ctx[2]; int i; ssl_ctx[0] = s_ctx; ssl_ctx[1] = c_ctx; for (i = 0; i < thread_number; i++) { BeginThread((void (*)(void *))ndoit, NULL, THREAD_STACK_SIZE, (void *)ssl_ctx); ThreadSwitchWithDelay(); } printf("reaping\n"); /* loop until all threads have signaled the semaphore */ for (i = 0; i < thread_number; i++) { MPKSemaphoreWait(ThreadSem); } printf("netware threads done (%d,%d)\n", s_ctx->references, c_ctx->references); }
// Use the socket in the CHandshakes object to listen for remote computers who want to connect to us // Returns true if we're listening, false if it didn't work BOOL CHandshakes::Listen() { if ( IsValid() ) return TRUE; // Make sure only one thread can execute the code of this method at a time CSingleLock pLock( &m_pSection, TRUE ); // When the method exits, local pLock will be destructed, and the lock released m_hSocket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP ); if ( ! IsValid() ) // Now, make sure it has been created { theApp.Message( MSG_ERROR, _T("Failed to create TCP socket. (1st Try)") ); // Second attempt m_hSocket = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP ); if ( ! IsValid() ) { theApp.Message( MSG_ERROR, _T("Failed to create TCP socket. (2nd Try)") ); return FALSE; } } // Disables the Nagle algorithm for send coalescing VERIFY( setsockopt( m_hSocket, IPPROTO_TCP, TCP_NODELAY, "\x01", 1) == 0 ); // Get our computer's Internet IP address and port number from the network object SOCKADDR_IN saHost = Network.m_pHost; // This is the address of our computer as visible to remote computers on the Internet // If the program connection settings disallow binding, zero the 4 bytes of the IP address if ( ! Settings.Connection.InBind ) saHost.sin_addr.s_addr = INADDR_ANY; // s_addr is the IP address formatted as a single u_long else { // Set the exclusive address option VERIFY( setsockopt( m_hSocket, SOL_SOCKET, SO_EXCLUSIVEADDRUSE, "\x01", 1 ) == 0 ); } // First attempt to bind socket if ( bind( m_hSocket, (SOCKADDR*)&saHost, sizeof( saHost ) ) != 0 ) { theApp.Message( MSG_ERROR, IDS_NETWORK_CANT_LISTEN, (LPCTSTR)CString( inet_ntoa( saHost.sin_addr ) ), htons( saHost.sin_port ) ); if ( saHost.sin_addr.s_addr == INADDR_ANY ) return FALSE; // Second attempt to bind socket saHost.sin_addr.s_addr = INADDR_ANY; if ( bind( m_hSocket, (SOCKADDR*)&saHost, sizeof( saHost ) ) != 0 ) { theApp.Message( MSG_ERROR, IDS_NETWORK_CANT_LISTEN, (LPCTSTR)CString( inet_ntoa( saHost.sin_addr ) ), htons( saHost.sin_port ) ); return FALSE; } } // Report that we are now listening on our IP address theApp.Message( MSG_INFO, IDS_NETWORK_LISTENING_TCP, (LPCTSTR)CString( inet_ntoa( saHost.sin_addr ) ), htons( saHost.sin_port ) ); // Set it up so that when a remote computer connects to us, the m_pWakeup event is fired WSAEventSelect( // Specify an event object to associate with the specified set of FD_XXX network events m_hSocket, // Our listening socket GetWakeupEvent(), // Our event, a CEvent object member variable FD_ACCEPT ); // The network event to trigger this is us accepting a remote computer's connection // Have the socket wait, listening for remote computer on the Internet to connect to it listen( // Place a socket in a state in which it is listening for an incoming connection m_hSocket, // Our socket 256 ); // Maximum length of the queue of pending connections, let 256 computers try to call us at once (do) Network.AcquireLocalAddress( m_hSocket ); // Create a new thread to run the ThreadStart method, passing it a pointer to this C return BeginThread( "Handshakes" ); }
void CDownloadTask::Allocate() { Construct( dtaskAllocate ); VERIFY( BeginThread( "Download Task : Allocate" ) ); }
void CLibraryMetaPanel::Update() { CSingleLock pLock1( &Library.m_pSection, TRUE ); CSingleLock pLock2( &m_pSection, TRUE ); CLibraryListPtr pSel( GetViewSelection() ); m_nSelected = pSel ? static_cast< int >( pSel->GetCount() ) : 0; // Show info for library files only CLibraryFile* pFirst = NULL; if ( m_nSelected ) { const CLibraryListItem& pItem = pSel->GetHead(); if ( pItem.Type == CLibraryListItem::LibraryFile ) pFirst = Library.LookupFile( pItem ); if ( pFirst == NULL ) m_nSelected = 0; } m_nIcon32 = m_nIcon48 = -1; if ( m_nSelected == 1 ) { m_nIndex = pFirst->m_nIndex; m_sName = pFirst->m_sName; m_sPath = pFirst->GetPath(); m_sFolder = pFirst->GetFolder(); m_sSize = Settings.SmartVolume( pFirst->GetSize() ); m_sType = ShellIcons.GetTypeString( m_sName ); m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 ); m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 ); m_nRating = pFirst->m_nRating; } else if ( m_nSelected > 1 ) { CString strFormat; LoadString( strFormat, IDS_LIBPANEL_MULTIPLE_FILES ); m_sName.Format( strFormat, m_nSelected ); QWORD nSize = 0; m_sFolder = pFirst->GetFolder(); m_nIcon32 = ShellIcons.Get( pFirst->GetPath(), 32 ); m_nIcon48 = ShellIcons.Get( pFirst->GetPath(), 48 ); m_nRating = 0; for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { CLibraryFile* pFile = Library.LookupFile( pSel->GetNext( pos ) ); if ( pFile == NULL ) continue; nSize += pFile->GetSize() / 1024; if ( pFile->IsAvailable() && pFile->GetFolder().CompareNoCase( m_sFolder ) ) { LoadString( m_sFolder, IDS_LIBPANEL_MULTIPLE_FOLDERS ); } int nIcon = ShellIcons.Get( pFile->GetPath(), 48 ); if ( nIcon != m_nIcon48 ) m_nIcon48 = -1; nIcon = ShellIcons.Get( pFile->GetPath(), 32 ); if ( nIcon != m_nIcon32 ) m_nIcon32 = -1; } m_sSize = Settings.SmartVolume( nSize ); m_sPath.Empty(); m_sType.Empty(); } m_pSchema = NULL; if ( pSel ) { for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { const CLibraryListItem& pItem = pSel->GetNext( pos ); if ( pItem.Type != CLibraryListItem::LibraryFile ) continue; CLibraryFile* pFile = Library.LookupFile( pItem ); if ( pFile == NULL ) continue; m_pSchema = pFile->m_pSchema; if ( m_pSchema ) break; } } if ( m_pServiceData ) { m_pMetadata->Setup( m_pServiceData ); } else { m_pMetadata->Setup( m_pSchema ); if ( m_pSchema && pSel ) { for ( POSITION pos = pSel->GetHeadPosition() ; pos ; ) { const CLibraryListItem& pItem = pSel->GetNext( pos ); if ( pItem.Type != CLibraryListItem::LibraryFile ) continue; if ( CLibraryFile* pFile = Library.LookupFile( pItem ) ) { if ( pFile->m_pMetadata != NULL && m_pSchema->Equals( pFile->m_pSchema ) ) { m_pMetadata->Combine( pFile->m_pMetadata ); } } } } } m_pMetadata->CreateLinks(); m_pMetadata->Clean( 4096 ); CClientDC dc( this ); if ( Settings.General.LanguageRTL ) SetLayout( dc.m_hDC, LAYOUT_BITMAPORIENTATIONPRESERVED ); SCROLLINFO pInfo; CRect rc; GetClientRect( &rc ); int nThumbSize = min( max( rc.Height() - 16, 64 ), (int)Settings.Library.ThumbSize ); int nHeight = 54 + m_pMetadata->Layout( &dc, rc.Width() - 24 - nThumbSize ); pInfo.cbSize = sizeof(pInfo); pInfo.fMask = SIF_ALL & ~SIF_TRACKPOS; pInfo.nMin = 0; pInfo.nMax = nHeight; pInfo.nPage = rc.Height(); pInfo.nPos = GetScrollPos( SB_VERT ); pInfo.nPos = max( 0, min( pInfo.nPos, pInfo.nMax - (int)pInfo.nPage + 1 ) ); SetScrollInfo( SB_VERT, &pInfo, TRUE ); if ( m_bForceUpdate || ( m_sThumb != m_sPath ) ) { m_bForceUpdate = FALSE; if ( m_bmThumb.m_hObject ) m_bmThumb.DeleteObject(); if ( ! IsThreadAlive() ) { BeginThread( "CtrlLibraryMetaPanel" ); } } pLock2.Unlock(); pLock1.Unlock(); Invalidate(); }
BOOL CCommMng::BeginRecvThread() { return BeginThread(); }