当前位置: 首页>>代码示例>>C++>>正文


C++ NewThread函数代码示例

本文整理汇总了C++中NewThread函数的典型用法代码示例。如果您正苦于以下问题:C++ NewThread函数的具体用法?C++ NewThread怎么用?C++ NewThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Execute

	// taskFunction: Task Function.
	//          arg: argument that will be passed to taskFunction. 
	void Execute(TaskFunction taskFunction, void *arg) {
		if (corePoolSize_ > currentThreads_) {
			NewThread();
			std::cout << "if (corePoolSize_ > currentThreads_) {" << '\n';
		} else if (currentThreads_ < maximumPoolSize_ && taskQueueSize_ + 1 > currentThreads_) {
			NewThread();
			std::cout << "} else if (currentThreads_ < maximumPoolSize_ && taskQueueSize_ + 1 > currentThreads_) {" << '\n';
		}

		Task newTask;
		newTask.taskFunction = taskFunction;
		newTask.arg = arg;

		while (!taskQueue_.push(newTask))
			;


	//	std::cout<<"push task ok.\n";

		++ taskQueueSize_;
		conditionVariable_.notify_one();
//		conditionVariable_.notify_all();

		std::cout<<"notify.\n";
	}
开发者ID:CCJY,项目名称:coliru,代码行数:27,代码来源:main.cpp

示例2: ZeroMalloc

// Initialize the IPsec server
IPSEC_SERVER *NewIPsecServer(CEDAR *cedar)
{
	IPSEC_SERVER *s;
	// Validate arguments
	if (cedar == NULL)
	{
		return NULL;
	}

	s = ZeroMalloc(sizeof(IPSEC_SERVER));

	s->LockSettings = NewLock();

	s->Cedar = cedar;

	AddRef(s->Cedar->ref);

	s->L2TP = NewL2TPServer(cedar);

	s->Ike = NewIKEServer(cedar, s);
	StrCpy(s->Ike->Secret, sizeof(s->Ike->Secret), IPSEC_DEFAULT_SECRET);

	s->UdpListener = NewUdpListener(IPsecServerUdpPacketRecvProc, s, &cedar->Server->ListenIP);

	s->EtherIPIdList = NewList(CmpEtherIPId);

	// Start an OS service monitoring thread
	s->OsServiceCheckThreadEvent = NewEvent();
	s->OsServiceCheckThread = NewThread(IPsecOsServiceCheckThread, s);

	return s;
}
开发者ID:macvk,项目名称:SoftEtherVPN,代码行数:33,代码来源:IPsec.c

示例3: LinkPaInit

// Initialize the packet adapter
bool LinkPaInit(SESSION *s)
{
	LINK *k;
	THREAD *t;
	// Validate arguments
	if (s == NULL || (k = (LINK *)s->PacketAdapter->Param) == NULL)
	{
		return false;
	}

	if (k->Halting || (*k->StopAllLinkFlag))
	{
		return false;
	}

	// Create a transmission packet queue
	k->SendPacketQueue = NewQueue();

	// Creat a link server thread
	t = NewThread(LinkServerSessionThread, (void *)k);
	WaitThreadInit(t);

	k->LastServerConnectionReceivedBlocksNum = 0;
	k->CurrentSendPacketQueueSize = 0;

	ReleaseThread(t);

	return true;
}
开发者ID:OchinDesh2OchinPur,项目名称:softether,代码行数:30,代码来源:Link.c

示例4: NewThreadEntryUPP

bool wxThreadInternal::Create(wxThread *thread, unsigned int stackSize)
{
    if ( s_threadEntry == NULL )
    {
        s_threadEntry = NewThreadEntryUPP( (ThreadEntryProcPtr) MacThreadStart ) ;
    }
    OSErr err = NewThread( kCooperativeThread,
                           s_threadEntry,
                           (void*) thread,
                           stackSize,
                           kNewSuspend,
                           &m_result,
                           &m_tid );

    if ( err != noErr )
    {
        wxLogSysError(_("Can't create thread"));
        return FALSE;
    }

    if ( m_priority != WXTHREAD_DEFAULT_PRIORITY )
    {
        SetPriority(m_priority);
    }

    m_state = STATE_NEW;

    return TRUE;
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:29,代码来源:thread.cpp

示例5: EiRebootServer

// Restarting the server
void EiRebootServer()
{
	THREAD *t;

	t = NewThread(EiRebootServerThread, NULL);
	ReleaseThread(t);
}
开发者ID:m-a-n-a-v,项目名称:SoftEtherVPN_Stable,代码行数:8,代码来源:EtherLog.c

示例6: ZeroMalloc

// Create a new SecureNAT
SNAT *SnNewSecureNAT(HUB *h, VH_OPTION *o)
{
	SNAT *s;
	THREAD *t;
	// Validate arguments
	if (h == NULL || o == NULL)
	{
		return NULL;
	}

	s = ZeroMalloc(sizeof(SNAT));
	s->Cedar = h->Cedar;
	s->Hub = h;
	s->lock = NewLock();

	// Create a NAT
	s->Nat = NiNewNatEx(s, o);

	// Initialize the virtual machine
	VirtualInit(s->Nat->Virtual);

	// Create a thread
	t = NewThread(SnSecureNATThread, s);
	WaitThreadInit(t);
	ReleaseThread(t);

	return s;
}
开发者ID:benapetr,项目名称:SoftEtherVPN,代码行数:29,代码来源:SecureNAT.c

示例7: NullPaInit

// Initialize the packet adapter
bool NullPaInit(SESSION *s)
{
	NULL_LAN *n;
	static UINT id_seed = 0;
	// Validate arguments
	if (s == NULL)
	{
		return false;
	}

	id_seed++;

	n = ZeroMalloc(sizeof(NULL_LAN));
	n->Id = id_seed;
	s->PacketAdapter->Param = (void *)n;

	n->Cancel = NewCancel();
	n->PacketQueue = NewQueue();
	n->Event = NewEvent();

	NullGenerateMacAddress(n->MacAddr, n->Id, 0);

	n->PacketGeneratorThread = NewThread(NullPacketGenerateThread, n);

	return true;
}
开发者ID:m-a-n-a-v,项目名称:SoftEtherVPN_Stable,代码行数:27,代码来源:NullLan.c

示例8: L3SwStart

// Start a Layer-3 switch
void L3SwStart(L3SW *s)
{
	// Validate arguments
	if (s == NULL)
	{
		return;
	}

	Lock(s->lock);
	{
		if (s->Active == false)
		{
			// Start if there is registered interface
			if (LIST_NUM(s->IfList) >= 1)
			{
				s->Halt = false;

				// Create a thread
				s->Thread = NewThread(L3SwThread, s);
				WaitThreadInit(s->Thread);
			}
		}
	}
	Unlock(s->lock);
}
开发者ID:BIGbozi,项目名称:SoftEtherVPN,代码行数:26,代码来源:Layer3.c

示例9: ZeroMalloc

// Create new VPN Azure client
AZURE_CLIENT *NewAzureClient(CEDAR *cedar, SERVER *server)
{
	AZURE_CLIENT *ac;
	// Validate arguments
	if (cedar == NULL || server == NULL)
	{
		return NULL;
	}

	ac = ZeroMalloc(sizeof(AZURE_CLIENT));

	ac->Cedar = cedar;

	ac->Server = server;

	ac->Lock = NewLock();

	ac->IsEnabled = false;

	ac->Event = NewEvent();

	// Start main thread
	ac->MainThread = NewThread(AcMainThread, ac);

	return ac;
}
开发者ID:alex-docker,项目名称:CE-dockerfiles,代码行数:27,代码来源:AzureClient.c

示例10: TCPAccepted

// Jump here if there is accepted connection in the TCP
void TCPAccepted(LISTENER *r, SOCK *s)
{
	TCP_ACCEPTED_PARAM *data;
	THREAD *t;
	char tmp[MAX_SIZE];
	UINT num_clients_from_this_ip = 0;
	CEDAR *cedar;
	// Validate arguments
	if (r == NULL || s == NULL)
	{
		return;
	}

	cedar = r->Cedar;

	num_clients_from_this_ip = GetNumIpClient(&s->RemoteIP);


	IPToStr(tmp, sizeof(tmp), &s->RemoteIP);

	data = ZeroMalloc(sizeof(TCP_ACCEPTED_PARAM));
	data->r = r;
	data->s = s;

	if (r->ThreadProc == TCPAcceptedThread)
	{
		Inc(cedar->AcceptingSockets);
	}

	t = NewThread(r->ThreadProc, data);
	WaitThreadInit(t);
	Free(data);
	ReleaseThread(t);
}
开发者ID:1nv4d3r5,项目名称:SoftEtherVPN,代码行数:35,代码来源:Listener.c

示例11: malloc

NetDownloader *FD_LoadPlugin()
{
    FileDownload *dnload;
    NetDownloader *plug = malloc(sizeof(NetDownloader));
    memset(plug, 0, sizeof(NetDownloader));
    M4_REG_PLUG(plug, M4FILEDOWNLOADER, "HTTP Downloader", "gpac distribution", 0);

    plug->CanHandleURL = FD_CanHandleURL;
    plug->GetMimeType = FD_GetMimeType;
    plug->Connect = FD_Connect;
    plug->FetchData = FD_FetchData;
    plug->Close= FD_Close;
    plug->GetCacheFileName = FD_GetCacheFileName;

    dnload = malloc(sizeof(FileDownload));
    memset(dnload, 0, sizeof(FileDownload));
    dnload->service_thread = NewThread();
    plug->net_status = DL_Unavailable;

    plug->priv = dnload;

    /*also init clock*/
    M4_InitClock();
    return plug;
}
开发者ID:DmitrySigaev,项目名称:DSMedia,代码行数:25,代码来源:file_dnload.c

示例12: malloc

BaseDecoder *NewISCodec(u32 PL)
{
	ISPriv *priv;
	SceneDecoder *tmp;
	
	tmp = (SceneDecoder*) malloc(sizeof(SceneDecoder));
	if (!tmp) return NULL;
	memset(tmp, 0, sizeof(SceneDecoder));

	priv = (ISPriv *) malloc(sizeof(ISPriv));
	memset(priv, 0, sizeof(ISPriv));

	priv->is_nodes = NewChain();
	priv->ddf = NewChain();

	tmp->privateStack = priv;

	tmp->AttachStream = IS_AttachStream;
	tmp->DetachStream = IS_DetachStream;
	tmp->GetCapabilities = IS_GetCapabilities;
	tmp->SetCapabilities = IS_SetCapabilities;
	tmp->ProcessData = IS_ProcessData;
	/*we don't use this...*/
	tmp->AttachScene = NULL;

	M4_REG_PLUG(tmp, M4SCENEDECODERINTERFACE, "GPAC InputSensor Decoder", "gpac distribution", 0)

#if M4_HTK_DEMO
	priv->th = NewThread();
#endif
	return (BaseDecoder *) tmp;
}
开发者ID:DmitrySigaev,项目名称:DSMedia,代码行数:32,代码来源:InputSensor.c

示例13: GetLocalHostIP4

// Create a new stack
NATIVE_STACK *NewNativeStack(CEDAR *cedar, char *device_name, char *mac_address_seed)
{
	ETH *eth;
	NATIVE_STACK *a;
	IP localhost;
	char tmp[64];
	bool release_cedar = false;
	// Validate arguments
	if (device_name == NULL || mac_address_seed == NULL)
	{
		return NULL;
	}

	GetLocalHostIP4(&localhost);

	// Open the Eth device
	eth = OpenEth(device_name, false, false, NULL);
	if (eth == NULL)
	{
		return NULL;
	}

	if (cedar == NULL)
	{
		cedar = NewCedar(NULL, NULL);
		release_cedar = true;
	}

	a = ZeroMalloc(sizeof(NATIVE_STACK));

	NewSocketPair(&a->Sock1, &a->Sock2, &localhost, 1, &localhost, 1);

	a->Cedar = cedar;
	AddRef(a->Cedar->ref);

	NsGenMacAddress(a->MacAddress, mac_address_seed, device_name);

	BinToStr(tmp, sizeof(tmp), a->MacAddress, sizeof(a->MacAddress));
	Debug("NewNativeStack: MAC Address = %s\n", tmp);

	a->Ipc = NewIPCBySock(cedar, a->Sock2, a->MacAddress);

	StrCpy(a->DeviceName, sizeof(a->DeviceName), device_name);

	a->Eth = eth;
	a->Cancel = EthGetCancel(eth);

	a->MainThread = NewThread(NsMainThread, a);

	if (release_cedar)
	{
		ReleaseCedar(cedar);
	}

	a->IsIpRawMode = a->Eth->IsRawIpMode;

	return a;
}
开发者ID:52M,项目名称:SoftEtherVPN,代码行数:59,代码来源:NativeStack.c

示例14: NewWorker

Worker* NewWorker(char* pipeName, aio4c_size_t bufferSize) {
    Worker* worker = NULL;
    ErrorCode code = AIO4C_ERROR_CODE_INITIALIZER;

    if ((worker = aio4c_malloc(sizeof(Worker))) == NULL) {
#ifndef AIO4C_WIN32
        code.error = errno;
#else /* AIO4C_WIN32 */
        code.source = AIO4C_ERRNO_SOURCE_SYS;
#endif /* AIO4C_WIN32 */
        code.size = sizeof(Worker);
        code.type = "Worker";
        Raise(AIO4C_LOG_LEVEL_ERROR, AIO4C_ALLOC_ERROR_TYPE, AIO4C_ALLOC_ERROR, &code);
        return NULL;
    }

    worker->queue      = NULL;
    worker->pool       = NULL;
    worker->writer     = NULL;
    worker->bufferSize = bufferSize;

    if (pipeName != NULL) {
        worker->pipe       = pipeName;
        worker->name       = aio4c_malloc(strlen(pipeName) + 1 + 7);
        if (worker->name != NULL) {
            snprintf(worker->name, strlen(pipeName) + 1 + 7, "%s-worker", pipeName);
        }
    } else {
        worker->pipe = NULL;
        worker->name = NULL;
    }

    worker->thread = NewThread(
            worker->name,
            _WorkerInit,
            _WorkerRun,
            _WorkerExit,
            (ThreadData)worker);

    if (worker->thread == NULL) {
        if (worker->name != NULL) {
            aio4c_free(worker->name);
        }
        aio4c_free(worker);
        return NULL;
    }

    if (!ThreadStart(worker->thread)) {
        if (worker->name != NULL) {
            aio4c_free(worker->name);
        }
        aio4c_free(worker);
        return NULL;
    }

    return worker;
}
开发者ID:blakawk,项目名称:Aio4c,代码行数:57,代码来源:worker.c

示例15: NsThreadMain

void
NsThreadMain(void *arg)
{
    ThreadArg   *argPtr = arg;
    Thread      *thrPtr;

    thrPtr = NewThread(argPtr);
    ns_free(argPtr);
    (*thrPtr->proc) (thrPtr->arg);
}
开发者ID:ayang64,项目名称:aolserver,代码行数:10,代码来源:thread.c


注:本文中的NewThread函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。