Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Reyhaneh Karimipour
xtrace-cpp
Commits
befbc2f5
Commit
befbc2f5
authored
May 21, 2019
by
DEPRECATED (Jonathan Mace) (Use @JonathanMace instead)
Browse files
Rearrange some of the files, to reduce the footprint of included headers
parent
90262630
Changes
10
Hide whitespace changes
Inline
Side-by-side
include/
atomlayer
.h
→
include/
baggage
.h
View file @
befbc2f5
#ifndef _
ATOM_LAYER
_H_
#define _
ATOM_LAYER
_H_
#ifndef _
BAGGAGE
_H_
#define _
BAGGAGE
_H_
#include
<iostream>
#include
<cstdint>
...
...
@@ -7,39 +7,46 @@
#include
<vector>
/*
This file defines the main interfaces (Atoms and Baggage) of the Brown Tracing Plane
Most interactions will be with Baggage and ThreadLocalBaggage
*/
// An atom is just an array of bytes
struct
Atom
{
std
::
vector
<
uint8_t
>
bytes
;
Atom
()
:
bytes
(
0
)
{}
Atom
(
int
x
)
:
bytes
(
4
)
{
for
(
unsigned
i
=
0
;
i
<
4
;
i
++
)
{
bytes
[
3
-
i
]
=
(
x
>>
(
i
*
8
));
}
}
Atom
(
int
size
)
:
bytes
(
size
)
{}
Atom
(
std
::
vector
<
uint8_t
>
bytes
)
:
bytes
(
bytes
)
{}
// Lexicographic comparison of two atoms
const
int
compare
(
const
Atom
&
other
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Atom
&
atom
);
};
// Baggage is an array of atoms
struct
Baggage
{
std
::
vector
<
Atom
>
atoms
;
Baggage
()
:
atoms
(
0
)
{}
// Duplicates this baggage
Baggage
branch
();
// Lexicographic merge of two baggage instances, as defined in the Brown Tracing Plane
static
Baggage
merge
(
Baggage
&
a
,
Baggage
&
b
);
// Serialize this baggage, as defined in the Brown Tracing Plane (length-prefix each atom in order)
std
::
vector
<
uint8_t
>
serialize
();
// Deserialize a serialized baggage instance, as defined in the Brown Tracing Plane
static
Baggage
deserialize
(
std
::
vector
<
uint8_t
>
bytes
);
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
os
,
const
Baggage
&
baggage
);
...
...
@@ -47,4 +54,18 @@ struct Baggage {
};
// Helper methods for storing a baggage instance in thread-local storage. Usage is optional, but very useful
namespace
ThreadLocalBaggage
{
Baggage
&
Get
();
// Get the current thread's baggage
Baggage
Take
();
// Get the current thread's baggage, and clear the thread-local storage
Baggage
Branch
();
// Get a copy of the current thread's baggage
void
Delete
();
// Delete the current thread's baggage
void
Set
(
Baggage
new_baggage
);
// Set the current thread's baggage to the provided baggage, destroying the previous baggage
void
Join
(
Baggage
&
otherBaggage
);
// Merge the current thread's baggage with the provided baggage
}
#endif
\ No newline at end of file
include/thread_local_baggage.h
deleted
100644 → 0
View file @
90262630
#ifndef _THREAD_LOCAL_BAGGAGE_H_
#define _THREAD_LOCAL_BAGGAGE_H_
#include
"atomlayer.h"
namespace
ThreadLocalBaggage
{
Baggage
&
Get
();
// Get the current thread's baggage
Baggage
Take
();
// Get the current thread's baggage, and clear the thread-local storage
Baggage
Branch
();
// Get a copy of the current thread's baggage
void
Delete
();
// Delete the current thread's baggage
void
Set
(
Baggage
new_baggage
);
void
Join
(
Baggage
&
otherBaggage
);
}
#endif
\ No newline at end of file
src/atomlayer.cpp
View file @
befbc2f5
#include
"
atomlayer
.h"
#include
"
baggage
.h"
#include
<iostream>
#include
<cstdint>
...
...
include
/baggageprotocol.h
→
src
/baggageprotocol.h
View file @
befbc2f5
#ifndef _BAGGAGE_PROTOCOL_H_
#define _BAGGAGE_PROTOCOL_H_
#include
"
atomlayer
.h"
#include
"
baggage
.h"
#include
"lexvarint.h"
#define ATOM_TYPE_MASK 0x80
...
...
include
/lexvarint.h
→
src
/lexvarint.h
View file @
befbc2f5
File moved
src/main.cc
View file @
befbc2f5
#include
<iostream>
#include
<vector>
#include
"atomlayer.h"
#include
"pubsub.h"
#include
<sstream>
#include
"baggage.h"
#include
"pubsub.h"
#include
"xtrace.h"
#include
"xtrace_baggage.h"
#include
"lexvarint.h"
#include
"baggageprotocol.h"
#include
"thread_local_baggage.h"
#include
"xtrace.h"
void
test_vector
(
std
::
vector
<
int
>
testv
)
{
testv
[
0
]
=
5
;
...
...
src/thread_local_baggage.cpp
View file @
befbc2f5
#include
"thread_local_baggage.h"
#include
"xtrace.h"
#include
"baggage.h"
thread_local
Baggage
current_threads_baggage
;
...
...
src/xtrace.cpp
View file @
befbc2f5
...
...
@@ -7,7 +7,8 @@
#include
<chrono>
#include
<time.h>
#include
"thread_local_baggage.h"
#include
"baggage.h"
#include
"xtrace.h"
#include
"xtrace.pb.h"
#include
"xtrace_baggage.h"
...
...
include
/xtrace.pb.h
→
src
/xtrace.pb.h
View file @
befbc2f5
File moved
include
/xtrace_baggage.h
→
src
/xtrace_baggage.h
View file @
befbc2f5
...
...
@@ -2,7 +2,7 @@
#define _XTRACE_BAGGAGE_H_
#include
"
thread_local_
baggage.h"
#include
"baggage.h"
namespace
XTraceBaggage
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment