Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "StudentFile.h"
- #include <chrono>
- #include <future>
- using namespace std;
- using namespace std::chrono;
- int main(int argc, char** argv){
- if (argc!=2)
- {
- cerr<<"Too much or too less arguments\n";
- exit(1);
- }
- StudentList* mylist;
- mylist=new StudentList;
- std::mutex* shared;
- //StudentFile mine(mylist,argv[1]);
- StudentFile* mine=new StudentFile(mylist,argv[1]);
- mine->set_mutex(shared);
- cout<<"hello from before the first thread \n";
- std::thread t1(&StudentFile::processFile,mine,mine);
- std::thread t2(&StudentFile::processFile,mine,mine);
- std::thread t3(&StudentFile::processFile,mine,mine);
- cout<<"hello from after the first thread \n";
- t1.join();
- t2.join();
- t3.join();
- cout<<"hello form after the mutex \n";
- /*
- std::future<int> a = std::async(std::launch::async, &StudentFile::processFile,mine, mine);
- std::future<int> b = std::async(std::launch::async, &StudentFile::processFile,mine, mine);
- cout<<"hello from the async mutex \n";
- std::chrono::milliseconds span (100);
- while (a.wait_for(std::chrono::milliseconds(10000)) != future_status::ready) cout << "a:" << a.get() << endl;;
- while (b.wait_for(std::chrono::milliseconds(10000)) != future_status::ready)cout << "b:" << b.get() << endl; ;
- */
- cout<<"hello world\n";
- delete mine;
- delete mylist;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement