?? fiber.cpp
字號(hào):
//// spectral toolkit // copyright (c) 2005 university corporation for atmospheric research// licensed under the gnu general public license//#include "fiber.h"namespace spectral{ /// Fiber destructor. fiber::~fiber() {} /// Fiber constructor. Initializes thread attributes. fiber::fiber() { running=0; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE); pthread_attr_setscope(&attr,PTHREAD_SCOPE_SYSTEM); } /// Thread creation method. Starts thread associated with this object /// which in turn invokes the virtual start method. /// \return 0 for success, pthread_create error code otherwise int fiber::spawn() { int r=pthread_create(&tid,&attr,fiber_wrapper,this); if(r==0) running=1; return(r); } /// Thread join method. Blocks until thread function returns if the thread /// is running, otherwise returns immediately. /// \return pointer returned from pthread_join void* fiber::join() { void *status=0; if(running) pthread_join(tid,&status); return(status); }} void* fiber_wrapper(void *object){ spectral::fiber *F=(spectral::fiber*)object; F->start(); return(0);}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -