#include <string.h>
#include <algorithm> // std::random_shuffle
#include <vector> // std::vector
+#include <unistd.h>
+#include <thread>
+
+
extern "C" {
#include "jerasure.h"
}
using namespace std;
-string cloud[5]={"dropboxida1","googleida1","megaida1","onedriveida1","pcloudida1"};
+string cloud[5]={"dropboxida1","googleida1","onedriveida2","onedriveida1","pcloudida1"};
void display(mylong *mat, int r, int c) {
// display(matC,t,t);
-
+ thread th[n];
//Save trunks
for(int i=0;i<n;i++) {
stringstream ss;
ss <<"lena_"<<i<<".png";
string str = ss.str();
saveFile((uint8_t*)&matC[i*len], str.c_str(),len*sizeof(mylong));
- sendChunk( str,i);
+// sendChunk( str,i);
+ th[i] = thread(sendChunk,str, i);
}
+ for(int i=0;i<n;i++) {
+ th[i].join();
+ }
+/* cout<<"sleep begin"<<endl;
+ sleep(2);
+ cout<<"sleep end"<<endl;
+*/
+
mylong *matCs = malloc(sizeof(mylong)*t*len);
mylong *matGs = malloc(sizeof(mylong)*t*t);
std::cout << "random chunk" << std::endl;
int ind=0;
+
+
+
for(int ii=0;ii<t;ii++) {
-// for(int i=n-1;i>=t;i--) {
-// for(int i=0;i<n;i+=2) {
auto i=myvector[ii];
std::cout << myvector[i] << " ";
ss <<"lena_"<<i<<".png";
string str = ss.str();
- retrieveChunk(str,i);
+// retrieveChunk(str,i);
+ th[ii] = thread(retrieveChunk,str, i);
+ }
+
+
+ ind=0;
+
+ for(int ii=0;ii<t;ii++) {
+
+ auto i=myvector[ii];
+ std::cout << myvector[i] << " ";
+
+
+ stringstream ss;
+ ss <<"lena_"<<i<<".png";
+ string str = ss.str();
+ th[ii].join();
readFile((uint8_t*)&matCs[ind*len], str.c_str(),len*sizeof(mylong));
// display(&matCs[ind*len],1,1);