Created
February 26, 2018 09:01
-
-
Save martende/7820f985194a5ab1eba808be151fb223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
#include <cstring> | |
#include <map> | |
#include <assert.h> | |
#include <memory> | |
#include <vector> | |
#include <set> | |
#include <ctime> | |
#include <chrono> | |
#include <boost/algorithm/string.hpp> | |
#include <bitset> | |
#include <thread> | |
#include <cstdarg> | |
#include <boost/asio.hpp> | |
#include <boost/log/utility/setup.hpp> | |
#include <fstream> | |
class Bucket2 { | |
public: | |
bool ok ; | |
int id ; | |
Bucket2(int); | |
//void dump(std::ostream &stream); | |
~Bucket2() { | |
printf("%d %p %p\n",this->id,this); | |
ok = false; | |
} | |
}; | |
Bucket2::Bucket2(int _id) { | |
ok = true; | |
id = _id; | |
} | |
//std::shared_ptr<Bucket> bucketGrid[MAX_PLATFORMS][MAX_SYMS][MAX_SYMS]; | |
std::shared_ptr<Bucket2> oneBucket; | |
double x; | |
void reader() { | |
while ( 1) { | |
auto b = oneBucket; | |
if ((bool)b) { | |
x = b->id; | |
} | |
} | |
} | |
void writer() { | |
int i=0; | |
while ( 1) { | |
//Bucket2 *bkt = new Bucket2(++i); | |
//auto tb = std::shared_ptr<Bucket2>(bkt); | |
oneBucket = std::make_shared<Bucket2>(++i); | |
} | |
} | |
int main(int argc,char** argv) { | |
std::thread _th1(reader); | |
std::thread _th2(writer); | |
_th1.join(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment