]>
Dogcows Code - chaz/yoink/blob - src/moof/thread.cc
2 /*] Copyright (c) 2009-2011, Charles McGarvey [*****************************
3 **] All rights reserved.
5 * Distributable under the terms and conditions of the 2-clause BSD license;
6 * see the file COPYING for a complete text of the license.
8 *****************************************************************************/
19 runloop_(new moof::runloop
) {}
21 thread
thread::detach(const function
& function
)
23 thread
* thread
= new moof::thread
;
24 thread
->function_
= function
;
29 thread
thread::detach(timer
& timer
)
31 thread
* thread
= new moof::thread
;
32 thread
->runloop().add_timer(timer
);
33 thread
->function_
= boost::bind(&moof::runloop::run
, thread
->runloop_
);
38 void thread::spawn(thread
* thread
)
40 thread
->thread_
= SDL_CreateThread(&thread::run
, (void*)thread
);
41 if (!thread
->thread_
) delete thread
;
44 int thread::run(void* arg
)
46 int code
= ((thread
*)arg
)->function_(*(thread
*)arg
);
55 SDL_KillThread(thread_
);
60 moof::runloop
& thread::runloop() const
65 moof::runloop
& thread::main_runloop()
67 static moof::runloop runloop
;
This page took 0.033624 seconds and 4 git commands to generate.