⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 factory.cpp

📁 Visual DSP++ VDK的应用举例
💻 CPP
字号:
/* =============================================================================
 *
 *  Description: This is a C++ implementation for Thread factory
 *
 * -----------------------------------------------------------------------------
 *  Comments: 
 *
 * ===========================================================================*/

#include "factory.h"
#include <stdio.h>

/******************************************************************************
 *  factory Constructor
 */
 
factory::factory(VDK::Thread::ThreadCreationBlock &tcb)
    : VDK::Thread(tcb)
{
}

/******************************************************************************
 *  factory Destructor
 */
 
factory::~factory()
{
}

/******************************************************************************
 *  factory Externally Accessable, Pre-Constructor Create Function
 */
 
VDK::Thread*
factory::Create(VDK::Thread::ThreadCreationBlock &tcb)
{
    return new (tcb) factory(tcb);
}

/******************************************************************************
 *  factory Run Function (factory's main{})
 */
 
void
factory::Run()
{
	int		count = 0;
	bool	should_loop = true;

	// Loop until we can't make any more threads
	while (should_loop == true)
	{
		// Create the thread
		VDK::CreateThread(kWorker);

		// Did the create go okay?
		if (VDK::GetLastThreadError() != VDK::kNoError)
			should_loop = false;
		else
			count++;
	}

	// Print the number of threads created
	printf("I was able to create %d threads\n", count);
	fflush(stdout);
}

/******************************************************************************
 *  factory Error Handler
 */
 
int
factory::ErrorHandler()
{
	/* TODO - Put this thread's error handling code HERE */

	/* The default ErrorHandler (called below) kills the thread */
	// return (VDK::Thread::ErrorHandler());

	// We don't want the thread destroyed, so just return 0
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -