本文整理汇总了C++中spawn_thread函数的典型用法代码示例。如果您正苦于以下问题:C++ spawn_thread函数的具体用法?C++ spawn_thread怎么用?C++ spawn_thread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spawn_thread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: do_threads
void do_threads(SSL_CTX *s_ctx, SSL_CTX *c_ctx)
{
SSL_CTX *ssl_ctx[2];
thread_id thread_ctx[MAX_THREAD_NUMBER];
int i;
ssl_ctx[0]=s_ctx;
ssl_ctx[1]=c_ctx;
for (i=0; i<thread_number; i++)
{
thread_ctx[i] = spawn_thread((thread_func)ndoit,
NULL, B_NORMAL_PRIORITY, (void *)ssl_ctx);
resume_thread(thread_ctx[i]);
}
printf("waiting...\n");
for (i=0; i<thread_number; i++)
{
status_t result;
wait_for_thread(thread_ctx[i], &result);
}
printf("beos threads done (%d,%d)\n",
s_ctx->references,c_ctx->references);
}
开发者ID:gosudream,项目名称:netbsd-src,代码行数:26,代码来源:mttest.c
示例2: PRINT
thread_id
BUrlRequest::Run()
{
// Thread already running
if (fRunning) {
PRINT(("BUrlRequest::Run() : Oops, already running ! "
"[urlProtocol=%p]!\n", this));
return fThreadId;
}
fThreadId = spawn_thread(BUrlRequest::_ThreadEntry, fThreadName,
B_NORMAL_PRIORITY, this);
if (fThreadId < B_OK)
return fThreadId;
fRunning = true;
status_t launchErr = resume_thread(fThreadId);
if (launchErr < B_OK) {
PRINT(("BUrlRequest::Run() : Failed to resume thread %" B_PRId32 "\n",
fThreadId));
return launchErr;
}
return fThreadId;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:27,代码来源:UrlRequest.cpp
示例3: BVolumeRoster
status_t QueryMenu::SetPredicate(const char *expr, BVolume *volume)
{
status_t status;
// Set the volume
if (volume == NULL)
{
BVolume bootVolume;
BVolumeRoster().GetBootVolume(&bootVolume);
if ( (status = fQuery->SetVolume(&bootVolume)) != B_OK)
return status;
}
else if ((status = fQuery->SetVolume(volume)) != B_OK)
return status;
if ((status = fQuery->SetPredicate(expr)) < B_OK)
return status;
// Force query thread to exit if still running
fCancelQuery = true;
fQueryLock.Lock();
// Remove all existing menu items (if any... )
RemoveEntries();
fQueryLock.Unlock();
// Resolve Query/Build Menu in seperate thread
thread_id thread;
thread = spawn_thread(query_thread, "query menu thread", B_NORMAL_PRIORITY, this);
return resume_thread(thread);
}
开发者ID:HaikuArchives,项目名称:BeMailDaemon,代码行数:33,代码来源:QueryMenu.cpp
示例4: resume_thread
KeepAlive::KeepAlive(PortTalker *port_talker) {
_keep_alive_thread_id = -1;
_port_talker = port_talker;
// Spawn listener thread (communication from remote machine)
resume_thread(_keep_alive_thread_id = spawn_thread(KeepAlive::_SpawnKeepAliveThread, "keep_alive", B_NORMAL_PRIORITY, this));
}
开发者ID:HaikuArchives,项目名称:Jabber4Haiku,代码行数:7,代码来源:KeepAlive.cpp
示例5: autolock
status_t
PowerStatusDriverInterface::StartWatching(BHandler* target)
{
BAutolock autolock(fListLocker);
status_t status = Monitor::StartWatching(target);
if (status != B_OK)
return status;
if (fThread > 0)
return B_OK;
fThread = spawn_thread(&_ThreadWatchPowerFunction, "PowerStatusThread",
B_LOW_PRIORITY, this);
if (fThread >= 0) {
fWaitSem = create_sem(0, "power status wait");
atomic_set(&fIsWatching, 1);
status = resume_thread(fThread);
} else
return fThread;
if (status != B_OK && fWatcherList.CountItems() == 0) {
atomic_set(&fIsWatching, 0);
delete_sem(fWaitSem);
fThread = -1;
fWaitSem = -1;
}
return status;
}
开发者ID:mmanley,项目名称:Antares,代码行数:32,代码来源:DriverInterface.cpp
示例6: spawn_thread
void
LJEventEditor::GetItem()
{
thread_id get_event_thread = spawn_thread(get_event,
"EventEditor::GetEvent", B_NORMAL_PRIORITY, this);
resume_thread(get_event_thread);
}
开发者ID:grahams,项目名称:alivejournal,代码行数:7,代码来源:LJEventEditor.cpp
示例7: _l
status_t AmInputQueue::StartPerforming()
{
BAutolock _l(mLock);
status_t result = B_ERROR;
// Start up record thread.
if (mPerformLock.Lock()) {
mPerformAvail = create_sem(0, "AmInputQueue Perform Avail");
if (mPerformAvail >= B_OK) {
mPerformThread = spawn_thread(PerformThreadEntry, "AmInputQueue Performer",
B_REAL_TIME_PRIORITY, this);
if (mPerformThread >= B_OK) {
resume_thread(mPerformThread);
result = B_OK;
} else {
result = mPerformThread;
delete_sem(mPerformAvail);
mPerformAvail = B_BAD_SEM_ID;
}
} else {
result = mPerformAvail;
}
mPerformLock.Unlock();
}
return result;
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:28,代码来源:AmInputQueue.cpp
示例8: BLooper
FractalEngine::FractalEngine(BHandler* parent, BLooper* looper)
:
BLooper("FractalEngine"),
fWidth(0), fHeight(0),
fRenderBuffer(NULL),
fRenderBufferLen(0),
fSubsampling(2),
fMessenger(parent, looper),
fIterations(1024),
fColorset(Colorset_Royal)
{
fDoSet = &FractalEngine::DoSet_Mandelbrot;
fRenderSem = create_sem(0, "RenderSem");
fRenderStoppedSem = create_sem(0, "RenderStopped");
system_info info;
get_system_info(&info);
fThreadCount = info.cpu_count;
if (fThreadCount > MAX_RENDER_THREADS)
fThreadCount = MAX_RENDER_THREADS;
for (uint8 i = 0; i < fThreadCount; i++) {
fRenderThreads[i] = spawn_thread(&FractalEngine::RenderThread,
BString().SetToFormat("RenderThread%d", i).String(),
B_NORMAL_PRIORITY, this);
resume_thread(fRenderThreads[i]);
}
}
开发者ID:looncraz,项目名称:haiku,代码行数:30,代码来源:FractalEngine.cpp
示例9: BWindowScreen
MacScreen::MacScreen(const BeOS_monitor_desc& monitor, const char *name, int mode_bit, status_t *error)
: BWindowScreen(name, 1 << mode_bit, error), tick_thread(-1)
, monitor(monitor)
{
// Set all variables
frame_backup = NULL;
palette_changed = false;
screen_active = false;
first_time = true;
quitting = false;
// Set relative mouse mode
ADBSetRelMouseMode(true);
// Create view to get mouse events
main_view = new BView(Frame(), NULL, B_FOLLOW_NONE, 0);
AddChild(main_view);
// Start 60Hz interrupt
tick_thread_active = true;
tick_thread = spawn_thread(tick_func, "Polling sucks...", B_DISPLAY_PRIORITY, this);
resume_thread(tick_thread);
// Add filter for keyboard and mouse events
BMessageFilter *filter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, filter_func);
AddCommonFilter(filter);
}
开发者ID:DavidLudwig,项目名称:macemu,代码行数:27,代码来源:video_beos.cpp
示例10: locker
bool
MessageLooper::Run()
{
BAutolock locker(this);
fQuitting = false;
char name[B_OS_NAME_LENGTH];
_GetLooperName(name, sizeof(name));
// Spawn our message-monitoring thread
fThread = spawn_thread(_message_thread, name, B_DISPLAY_PRIORITY, this);
if (fThread < B_OK) {
fQuitting = true;
return false;
}
if (resume_thread(fThread) != B_OK) {
fQuitting = true;
kill_thread(fThread);
fThread = -1;
return false;
}
return true;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:26,代码来源:MessageLooper.cpp
示例11: setup_server
void
setup_server()
{
sockaddr_in address;
memset(&address, 0, sizeof(address));
address.sin_len = sizeof(sockaddr_in);
address.sin_family = AF_INET;
address.sin_port = htons(1024);
address.sin_addr.s_addr = INADDR_ANY;
status_t status = socket_bind(gServerSocket, (struct sockaddr*)&address,
sizeof(struct sockaddr));
if (status < B_OK) {
fprintf(stderr, "tcp_tester: cannot bind server: %s\n", strerror(status));
exit(1);
}
status = socket_listen(gServerSocket, 40);
if (status < B_OK) {
fprintf(stderr, "tcp_tester: server cannot listen: %s\n",
strerror(status));
exit(1);
}
thread_id serverThread = spawn_thread(server_thread, "server",
B_NORMAL_PRIORITY, NULL);
if (serverThread < B_OK) {
fprintf(stderr, "tcp_tester: cannot start server: %s\n",
strerror(serverThread));
exit(1);
}
resume_thread(serverThread);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:33,代码来源:tcp_shell.cpp
示例12: main
int
main()
{
status_t s;
ssize_t size;
int32 code;
id = create_port(1, "test port");
printf("created port %ld\n", id);
s = write_port(id, 0x1234, data, 10);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
size = read_port(id, &code, data, sizeof(data));
printf("read port code %lx, size %ld (0x%08lx) (%s)\n", code, size, size, strerror(size));
printf("port_buffer_size should block for 5 seconds now, as port is empty\n");
thread_id thread = spawn_thread(test_thread, "test thread", B_NORMAL_PRIORITY, NULL);
resume_thread(thread);
snooze(5000000);
printf("write port...\n");
s = write_port(id, 0x5678, data, 20);
printf("write port result 0x%08lx (%s)\n", s, strerror(s));
printf("waiting for thread to terminate\n");
wait_for_thread(thread, &s);
return 0;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:31,代码来源:port_wakeup_test_3.cpp
示例13: spawn_thread
// _InitServerInfoConnectionListener
status_t
NetFSServer::_InitServerInfoConnectionListener()
{
// spawn the listener thread
fServerInfoConnectionListener = spawn_thread(
&_ServerInfoConnectionListenerEntry,
"server info connection listener", B_NORMAL_PRIORITY, this);
if (fServerInfoConnectionListener < 0)
return fServerInfoConnectionListener;
// create a listener socket
fServerInfoConnectionListenerSocket = socket(AF_INET, SOCK_STREAM, 0);
if (fServerInfoConnectionListenerSocket < 0)
return errno;
// bind it to the port
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(kDefaultServerInfoPort);
addr.sin_addr.s_addr = INADDR_ANY;
if (bind(fServerInfoConnectionListenerSocket, (sockaddr*)&addr,
sizeof(addr)) < 0) {
return errno;
}
// start listening
if (listen(fServerInfoConnectionListenerSocket, 5) < 0)
return errno;
return B_OK;
}
开发者ID:Ithamar,项目名称:haiku,代码行数:28,代码来源:NetFSServer.cpp
示例14: this_team
sptr<IProcess> BProcess::Spawn(const SString& name, const SValue& env, uint32_t flags)
{
#if BINDER_DEBUG_LIB
(void)env;
(void)flags;
team_id teamid = this_team()+atomic_add(&nextFakeProcessIDDelta,1);
bout << "spawning pretend team " << teamid << endl;
SysHandle thid = spawn_thread((thread_entry)pretend_team,"pretend_team",B_NORMAL_PRIORITY,(void *)teamid);
ErrFatalErrorIf(thid < 0, "could not spawn pretend_team");
sptr<IProcess> team
= IProcess::AsInterface(SLooper::GetRootObject(thid, teamid));
ErrFatalErrorIf(team == NULL, "pretend_team gave us a root object that wasn't an IProcess");
#else
SString fullName("/binder_team");
mkdir(fullName.String(), S_IRWXU|S_IRWXG|S_IRWXO);
fullName += "/";
if (name != "") fullName += name;
else fullName += "anonymous";
symlink("/system/servers/remote_place", fullName.String());
sptr<IBinder> teamBinder = SpawnFile(fullName, env, flags);
sptr<IProcess> team = IProcess::AsInterface(teamBinder);
ErrFatalErrorIf(team == NULL && teamBinder != NULL, "remote_place did not publish an IProcess");
#endif // BINDER_DEBUG_LIB
return team;
}
开发者ID:wenj91,项目名称:OpenBinder,代码行数:30,代码来源:Process.cpp
示例15: TRACE
void
VideoProducer::_HandleStart(bigtime_t performanceTime)
{
// Start producing frames, even if the output hasn't been connected yet.
TRACE("_HandleStart(%Ld)\n", performanceTime);
if (fRunning) {
TRACE("_HandleStart: Node already started\n");
return;
}
fFrame = 0;
fFrameBase = 0;
fPerformanceTimeBase = performanceTime;
fFrameSync = create_sem(0, "frame synchronization");
if (fFrameSync < B_OK)
return;
fThread = spawn_thread(_FrameGeneratorThreadEntry, "frame generator",
B_NORMAL_PRIORITY, this);
if (fThread < B_OK) {
delete_sem(fFrameSync);
return;
}
resume_thread(fThread);
fRunning = true;
return;
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:30,代码来源:VideoProducer.cpp
示例16: gwthread_create_real
long gwthread_create_real(gwthread_func_t *func, const char *name, void *arg)
{
int sigtrick = 0;
sigset_t old_signal_set;
long thread_id;
/*
* We want to make sure that only the main thread handles signals,
* so that each signal is handled exactly once. To do this, we
* make sure that each new thread has all the signals that we
* handle blocked. To avoid race conditions, we block them in
* the spawning thread first, then create the new thread (which
* inherits the settings), and then restore the old settings in
* the spawning thread. This means that there is a brief period
* when no signals will be processed, but during that time they
* should be queued by the operating system.
*/
if (gwthread_self() == MAIN_THREAD_ID)
sigtrick = block_user_signals(&old_signal_set) == 0;
thread_id = spawn_thread(func, name, arg);
/*
* Restore the old signal mask. The new thread will have
* inherited the resticted one, but the main thread needs
* the old one back.
*/
if (sigtrick)
restore_user_signals(&old_signal_set);
return thread_id;
}
开发者ID:Jayriq,项目名称:kannel-gateway,代码行数:32,代码来源:gwthread-pthread.c
示例17: main
int
main()
{
// Test program to reproduce bug #2562. Is finished quickly and must be run
// in a loop to reproduce the bug.
// install signal handler
if (signal(SIGUSR1, signal_handler) == SIG_ERR) {
fprintf(stderr, "Error: Failed to install signal handler: %s\n",
strerror(errno));
exit(1);
}
// start signal thread
thread_id signalThread = spawn_thread(&signal_pusher, "signal pusher",
B_NORMAL_PRIORITY, NULL);
resume_thread(signalThread);
allocator_thread(0);
kill_thread(signalThread);
snooze(1000);
printf("test successful, handled %lld signals\n", sHandledSignals);
return 0;
}
开发者ID:looncraz,项目名称:haiku,代码行数:27,代码来源:signal_in_allocator_test2.cpp
示例18: TStreamBuff
TFTPClient::TFTPClient()
{
fAbort = false;
fControlEndpoint = -1;
fWaitTime = 60000000;
fReplyBuff = new TStreamBuff(SB_UNKNOWN_TEXT_TYPE);
fSemID = -1;
fReceiverThreadID = -1;
fSemID = create_sem(1, "stream_buff");
if (fSemID < 0) {
fStatus = fSemID;
fStrError.SetTo(strerror(fStatus));
return;
}
// 受信スレッド生成
fReceiverThreadID = spawn_thread(TFTPClient::ReceiverThread,
"receiver_thread", B_NORMAL_PRIORITY, this);
if (fReceiverThreadID < 0) {
fStatus = fReceiverThreadID;
fStrError.SetTo(strerror(fStatus));
return;
}
fStatus = B_OK;
}
开发者ID:ModeenF,项目名称:FtpPositive,代码行数:27,代码来源:FTPClient.cpp
示例19: BDirectWindow
GX_BDirectWindow::GX_BDirectWindow(BRect window_rect, const char *pTitle)
: BDirectWindow(window_rect, pTitle, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{
m_pInstance = this;
m_bConnected = false;
m_bDirty = false;
BView *view = g_pApp->CreateSubview(this);
if (view)
{
AddChild(view);
}
AddShortcut('\n', B_COMMAND_KEY, new BMessage(MSG_SYSAPPLICATION_SWITCHFS));
AddShortcut('x', B_COMMAND_KEY, new BMessage(MSG_SYSAPPLICATION_CLOSE));
m_SemID = create_sem(1, "BDirectWindow lock sem");
m_DrawThread = spawn_thread(RenderThread, "drawing_thread", B_NORMAL_PRIORITY, (void *) this);
if (m_DrawThread<0)
{
printf("Can't spawn drawing thread, bailing out...\n" );
}
Center();
resume_thread(m_DrawThread);
}
开发者ID:cbxbiker61,项目名称:nogravity,代码行数:26,代码来源:gx_bdirectwindow.cpp
示例20: QLatin1String
QHaikuIntegration *QHaikuIntegration::createHaikuIntegration(const QStringList& parameters, int &argc, char **argv)
{
thread_id my_thread;
QString appSignature = QLatin1String("application/x-vnd.qt5-") + QCoreApplication::applicationName();
haikuApplication = new HQApplication(appSignature.toUtf8());
be_app = haikuApplication;
my_thread = spawn_thread(AppThread, "BApplication_thread", B_NORMAL_PRIORITY, (void*)haikuApplication);
resume_thread(my_thread);
haikuApplication->UnlockLooper();
if(argc==1) {
for(int i=0;i<100;i++) {
if(haikuApplication->RefHandled) {
BPath p(&haikuApplication->Ref);
argc = 2;
argv[1]=strdup(p.Path());
argv[2]=0;
break;
}
snooze(1000);
}
}
return new QHaikuIntegration(parameters, argc, argv);
}
开发者ID:threedeyes,项目名称:QPAHaikuExp,代码行数:27,代码来源:qhaikuintegration_haiku.cpp
注:本文中的spawn_thread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论