You've already forked mariadb-columnstore-engine
mirror of
https://github.com/mariadb-corporation/mariadb-columnstore-engine.git
synced 2025-12-15 12:09:09 +03:00
Made IOCoordinator a singleton vs a global.
This commit is contained in:
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,12 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
storagemanager::IOCoordinator *ioc = NULL;
|
||||||
|
boost::mutex m;
|
||||||
|
}
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -21,6 +27,17 @@ IOCoordinator::~IOCoordinator()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IOCoordinator * IOCoordinator::get()
|
||||||
|
{
|
||||||
|
if (ioc)
|
||||||
|
return ioc;
|
||||||
|
boost::mutex::scoped_lock s(m);
|
||||||
|
if (ioc)
|
||||||
|
return ioc;
|
||||||
|
ioc = new IOCoordinator();
|
||||||
|
return ioc;
|
||||||
|
}
|
||||||
|
|
||||||
void IOCoordinator::willRead(const char *, off_t, size_t)
|
void IOCoordinator::willRead(const char *, off_t, size_t)
|
||||||
{
|
{
|
||||||
// no cache yet
|
// no cache yet
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
@@ -15,7 +16,7 @@ namespace storagemanager
|
|||||||
class IOCoordinator : public boost::noncopyable
|
class IOCoordinator : public boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IOCoordinator();
|
static IOCoordinator *get();
|
||||||
virtual ~IOCoordinator();
|
virtual ~IOCoordinator();
|
||||||
|
|
||||||
void willRead(const char *filename, off_t offset, size_t length);
|
void willRead(const char *filename, off_t offset, size_t length);
|
||||||
@@ -27,6 +28,9 @@ class IOCoordinator : public boost::noncopyable
|
|||||||
int stat(const char *path, struct stat *out);
|
int stat(const char *path, struct stat *out);
|
||||||
int truncate(const char *path, size_t newsize);
|
int truncate(const char *path, size_t newsize);
|
||||||
int unlink(const char *path);
|
int unlink(const char *path);
|
||||||
|
|
||||||
|
private:
|
||||||
|
IOCoordinator();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ PosixTask::PosixTask(int _sock, uint _length) :
|
|||||||
bufferLen(0),
|
bufferLen(0),
|
||||||
socketReturned(false)
|
socketReturned(false)
|
||||||
{
|
{
|
||||||
|
ioc = IOCoordinator::get();
|
||||||
}
|
}
|
||||||
|
|
||||||
PosixTask::~PosixTask()
|
PosixTask::~PosixTask()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "IOCoordinator.h"
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
@@ -30,6 +31,8 @@ class PosixTask
|
|||||||
void returnSocket();
|
void returnSocket();
|
||||||
void socketError();
|
void socketError();
|
||||||
|
|
||||||
|
IOCoordinator *ioc;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PosixTask();
|
PosixTask();
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
extern storagemanager::IOCoordinator *ioc;
|
|
||||||
|
|
||||||
namespace storagemanager
|
namespace storagemanager
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -10,17 +10,13 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
#include "SessionManager.h"
|
#include "SessionManager.h"
|
||||||
#include "IOCoordinator.h"
|
|
||||||
|
|
||||||
using namespace storagemanager;
|
using namespace storagemanager;
|
||||||
|
|
||||||
IOCoordinator *ioc;
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
SessionManager sessionManager = SessionManager();
|
SessionManager sessionManager = SessionManager();
|
||||||
ioc = new IOCoordinator();
|
|
||||||
|
|
||||||
ret = sessionManager.start();
|
ret = sessionManager.start();
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include "TruncateTask.h"
|
#include "TruncateTask.h"
|
||||||
#include "ListDirectoryTask.h"
|
#include "ListDirectoryTask.h"
|
||||||
#include "PingTask.h"
|
#include "PingTask.h"
|
||||||
#include "IOCoordinator.h"
|
|
||||||
#include "messageFormat.h"
|
#include "messageFormat.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -26,8 +25,6 @@
|
|||||||
using namespace storagemanager;
|
using namespace storagemanager;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
IOCoordinator *ioc;
|
|
||||||
|
|
||||||
struct scoped_closer {
|
struct scoped_closer {
|
||||||
scoped_closer(int f) : fd(f) { }
|
scoped_closer(int f) : fd(f) { }
|
||||||
~scoped_closer() {
|
~scoped_closer() {
|
||||||
@@ -403,7 +400,6 @@ bool pingtask()
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
ioc = new IOCoordinator();
|
|
||||||
cout << "connecting" << endl;
|
cout << "connecting" << endl;
|
||||||
makeConnection();
|
makeConnection();
|
||||||
cout << "connected" << endl;
|
cout << "connected" << endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user