-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
169 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Created by Shuai on 6/25/17. | ||
// | ||
|
||
#include "frame.h" | ||
#include "sched.h" | ||
|
||
using namespace janus; | ||
|
||
Scheduler* ExternCFrame::CreateScheduler() { | ||
Scheduler* sched = new ExternCScheduler(); | ||
sched->frame_ = this; | ||
return sched; | ||
} | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by Shuai on 6/25/17. | ||
// | ||
|
||
#pragma once | ||
|
||
#include "../frame.h" | ||
|
||
namespace janus { | ||
|
||
|
||
class ExternCFrame : public Frame { | ||
public: | ||
ExternCFrame() : Frame(MODE_EXTERNC) { } | ||
Scheduler *CreateScheduler() override; | ||
}; | ||
|
||
} // namespace janus |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Created by Shuai on 6/27/17. | ||
// | ||
|
||
#include "sched.h" | ||
|
||
|
||
extern "C" { | ||
|
||
#include "../../extern_interface/scheduler.h" | ||
|
||
} | ||
|
||
namespace janus { | ||
|
||
bool ExternCScheduler::HandleConflicts(DTxn &dtxn, | ||
innid_t inn_id, | ||
vector<string> &conflicts) { | ||
// TODO call C interface | ||
vector<_c_conflict_id_t> cf(conflicts.size()); | ||
for (int i = 0; i < conflicts.size(); i++) { | ||
cf[i].key = const_cast<char*>(conflicts[i].data()); | ||
cf[i].ptr_mem = nullptr; | ||
cf[i].rw_flag = 1; | ||
cf[i].sz_key = conflicts[i].size(); | ||
} | ||
int r = ::handle_conflicts(dtxn.tid_, conflicts.size(), cf.data()); | ||
return (r > 0); | ||
return true; | ||
} | ||
|
||
} // namespace janus |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "../scheduler.h" | ||
|
||
// | ||
// Created by Shuai on 6/25/17. | ||
// | ||
|
||
namespace janus { | ||
|
||
class ExternCScheduler : public Scheduler { | ||
using Scheduler::Scheduler; | ||
public: | ||
virtual bool HandleConflicts(DTxn& dtxn, | ||
innid_t inn_id, | ||
vector<string>& conflicts) override; | ||
|
||
}; | ||
|
||
} // namespace janus |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
#include "../frame.h" | ||
|
||
namespace rococo { | ||
namespace janus { | ||
|
||
class JanusFrame : public Frame { | ||
public: | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "scheduler.h" | ||
|
||
// test for c-cpp bridge | ||
int hello_c() { | ||
return 0; | ||
} | ||
|
||
|
||
//// a sample implementation for "none" mode. | ||
int32_t handle_conflicts(int64_t txn_id, | ||
int32_t n_confict, | ||
_c_conflict_id_t* conflicts) { | ||
// never pause. | ||
return 0; | ||
} | ||
|
||
int64_t poll_executable() { | ||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include "inttypes.h" | ||
|
||
/** | ||
* This is a C interface for external concurrency control protocols. | ||
* @param txn_id the transaction id greater than 0 | ||
* @param rw_flag 0 for read for read, 1 for write. | ||
* @return 0 for continue and 1 for pause. | ||
*/ | ||
|
||
typedef struct { | ||
int32_t rw_flag; | ||
char* key; | ||
int32_t sz_key; | ||
void** ptr_mem; | ||
} _c_conflict_id_t; | ||
|
||
int hello_c(); | ||
|
||
int32_t handle_conflicts( | ||
int64_t txn_id, | ||
int32_t n_confict, | ||
_c_conflict_id_t* conflicts | ||
); | ||
|
||
/** | ||
* | ||
* @return the transaction id for next executable 0 for nothing. | ||
*/ | ||
int64_t poll_executable(); | ||
|
This file contains 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