mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-14 10:36:34 +01:00
More missing stuff...
git-svn-id: svn://localhost/ardour2/trunk@2645 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
a313924b77
commit
aa6faa86b5
32 changed files with 5856 additions and 0 deletions
49
libs/glibmm2/examples/thread/threadpool.cc
Normal file
49
libs/glibmm2/examples/thread/threadpool.cc
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <glibmm/random.h>
|
||||
#include <glibmm/thread.h>
|
||||
#include <glibmm/threadpool.h>
|
||||
#include <glibmm/timer.h>
|
||||
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
Glib::StaticMutex mutex = GLIBMM_STATIC_MUTEX_INIT;
|
||||
|
||||
void print_char(char c)
|
||||
{
|
||||
Glib::Rand rand;
|
||||
|
||||
for(int i = 0; i < 100; ++i)
|
||||
{
|
||||
{
|
||||
Glib::Mutex::Lock lock (mutex);
|
||||
std::cout << c;
|
||||
std::cout.flush();
|
||||
}
|
||||
Glib::usleep(rand.get_int_range(10000, 100000));
|
||||
}
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
Glib::thread_init();
|
||||
|
||||
Glib::ThreadPool pool (10);
|
||||
|
||||
for(char c = 'a'; c <= 'z'; ++c)
|
||||
{
|
||||
pool.push(sigc::bind<1>(sigc::ptr_fun(&print_char), c));
|
||||
}
|
||||
|
||||
pool.shutdown();
|
||||
|
||||
std::cout << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue