Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / devel / devel.dmacvicar / multiple-download.cc
1 #include <sys/time.h>
2
3 #include <iostream>
4 #include <fstream>
5
6 #include <boost/thread/thread.hpp>
7 #include <boost/thread/mutex.hpp>
8
9 #include <zypp/base/Logger.h>
10 #include <zypp/ZYpp.h>
11 #include <zypp/ZYppFactory.h>
12
13 #include "zypp/Product.h"
14 #include "zypp/Package.h"
15
16 #include "zypp/TmpPath.h"
17
18 #include "zypp/sat/Pool.h"
19
20 #include "zypp/PoolQuery.h"
21
22 using namespace std;
23 using namespace zypp;
24 using namespace zypp::repo;
25
26 bool result_cb( const ResObject::Ptr &r )
27 {
28   cout << r << endl;
29 }
30
31 boost::mutex io_mutex;
32
33 struct Counter
34 {
35   Counter(int id) : id(id) { }
36   void operator()()
37   {
38     for (int i = 0; i < 10; ++i)
39     {
40       //boost::mutex::scoped_lock lock(io_mutex);
41       std::cout << id << ": " << i << std::endl;
42       if ( i == 4 )
43       {
44         boost::thread thrd2(Counter(3));
45       }
46     }
47   }
48   int id;
49 };
50
51 int main(int argc, char **argv)
52 {
53     try
54     {
55       ZYpp::Ptr z = getZYpp();
56     
57       boost::thread thrd1(Counter(1));
58       boost::thread thrd2(Counter(2));
59       thrd1.join();
60       thrd2.join();
61       return 0;
62       
63       //z->initializeTarget("/");
64       //z->target()->load();
65
66 //      sat::Pool::instance().addRepoSolv("./foo.solv");
67
68 //       for ( ResPool::const_iterator it = z->pool().begin(); it != z->pool().end(); ++it )
69 //       {
70 //         ResObject::constPtr res = it->resolvable();
71 //         if ( res->name() == "kde4-kcolorchooser")
72 //         {
73 //           cout << res << endl;
74 //           cout << res->summary() << " | " << res->size() << endl;
75 //         }
76 //       }
77
78     }
79     catch ( const Exception &e )
80     {
81       ZYPP_CAUGHT(e);
82       cout << e.msg() << endl;
83     }
84     
85     return 0;
86 }
87
88
89