Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ SpaceAfterTemplateKeyword: true

# --- Assignments & Alignments ---
AlignConsecutiveAssignments:
Enabled: true
Enabled: false
AlignConsecutiveDeclarations: false

# --- Switch/Case ---
Expand Down
22 changes: 11 additions & 11 deletions core/include/join/acceptor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ namespace join
{
public:
using Endpoint = typename Protocol::Endpoint;
using Socket = typename Protocol::Socket;
using Stream = typename Protocol::Stream;
using Socket = typename Protocol::Socket;
using Stream = typename Protocol::Stream;

/**
* @brief create the acceptor instance.
Expand Down Expand Up @@ -67,7 +67,7 @@ namespace join
: _handle (other._handle)
, _protocol (other._protocol)
{
other._handle = -1;
other._handle = -1;
other._protocol = Protocol ();
}

Expand All @@ -80,10 +80,10 @@ namespace join
{
this->close ();

this->_handle = other._handle;
this->_handle = other._handle;
this->_protocol = other._protocol;

other._handle = -1;
other._handle = -1;
other._protocol = Protocol ();

return *this;
Expand Down Expand Up @@ -192,7 +192,7 @@ namespace join
}

sock._remote = Endpoint (reinterpret_cast<struct sockaddr*> (&sa), sa_len);
sock._state = Socket::Connected;
sock._state = Socket::Connected;

if (sock.protocol () == IPPROTO_TCP)
{
Expand Down Expand Up @@ -293,8 +293,8 @@ namespace join
{
public:
using Endpoint = typename Protocol::Endpoint;
using Socket = typename Protocol::Socket;
using Stream = typename Protocol::Stream;
using Socket = typename Protocol::Socket;
using Stream = typename Protocol::Stream;

/**
* @brief create the acceptor instance.
Expand Down Expand Up @@ -395,8 +395,8 @@ namespace join
BasicTlsAcceptor& operator= (BasicTlsAcceptor&& other)
{
BasicStreamAcceptor<Protocol>::operator= (std::move (other));
_tlsContext = std::move (other._tlsContext);
_sessionId = other._sessionId;
_tlsContext = std::move (other._tlsContext);
_sessionId = other._sessionId;
other._sessionId = 0;
return *this;
}
Expand All @@ -420,7 +420,7 @@ namespace join
}

sock._remote = Endpoint (reinterpret_cast<struct sockaddr*> (&sa), sa_len);
sock._state = Socket::Connected;
sock._state = Socket::Connected;

sock.setOption (Socket::NoDelay, 1);
sock.setMode (Socket::NonBlocking);
Expand Down
14 changes: 7 additions & 7 deletions core/include/join/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ namespace join
static_assert (Count > 0, "count must be at least 1");
static_assert (Count <= UINT32_MAX, "count exceeds tagged index capacity (~256 GB)");

using Chunk = BasicChunk<Size>;
using Chunk = BasicChunk<Size>;
using Segment = BasicSegment<Size>;

/// total number of chunks per pool.
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace join
*/
BasicPool& operator= (BasicPool&& other) noexcept
{
_segment = other._segment;
_segment = other._segment;
other._segment = nullptr;
return *this;
}
Expand Down Expand Up @@ -234,12 +234,12 @@ namespace join
{
TaggedIndex cur, next;
next.idx = static_cast<uint32_t> (reinterpret_cast<Chunk*> (p) - _segment->_chunks);
cur.raw = _segment->_head.load (std::memory_order_relaxed);
cur.raw = _segment->_head.load (std::memory_order_relaxed);

for (;;)
{
_segment->_chunks[next.idx]._next = cur.idx;
next.gen = cur.gen + 1;
next.gen = cur.gen + 1;

if (JOIN_LIKELY (_segment->_head.compare_exchange_weak (cur.raw, next.raw, std::memory_order_release,
std::memory_order_relaxed)))
Expand All @@ -257,8 +257,8 @@ namespace join
bool owns (void* p) const noexcept
{
auto base = reinterpret_cast<std::uintptr_t> (_segment->_chunks);
auto end = base + (_count * _stride);
auto ptr = reinterpret_cast<std::uintptr_t> (p);
auto end = base + (_count * _stride);
auto ptr = reinterpret_cast<std::uintptr_t> (p);
return ((ptr >= base) && (ptr < end));
}

Expand Down Expand Up @@ -375,7 +375,7 @@ namespace join
BasicArena& operator= (BasicArena&& other) noexcept
{
_backend = std::move (other._backend);
_pools = std::move (other._pools);
_pools = std::move (other._pools);
return *this;
}

Expand Down
26 changes: 13 additions & 13 deletions core/include/join/clock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ namespace join
*/
struct NanoClock
{
using rep = int64_t;
using period = std::nano;
using duration = std::chrono::nanoseconds;
using time_point = std::chrono::time_point<NanoClock>;
static constexpr bool is_steady = true;
using rep = int64_t;
using period = std::nano;
using duration = std::chrono::nanoseconds;
using time_point = std::chrono::time_point<NanoClock>;
static constexpr bool is_steady = true;
static time_point now () noexcept = delete;
};

Expand Down Expand Up @@ -82,10 +82,10 @@ namespace join
class Monotonic
{
public:
using Duration = std::chrono::nanoseconds;
using Duration = std::chrono::nanoseconds;
using TimePoint = std::chrono::time_point<NanoClock>;
using Timer = BasicTimer<Monotonic>;
using Stats = BasicStats<Monotonic>;
using Timer = BasicTimer<Monotonic>;
using Stats = BasicStats<Monotonic>;

/**
* @brief default constructor.
Expand Down Expand Up @@ -119,9 +119,9 @@ namespace join
class MonotonicRaw
{
public:
using Duration = std::chrono::nanoseconds;
using Duration = std::chrono::nanoseconds;
using TimePoint = std::chrono::time_point<NanoClock>;
using Stats = BasicStats<MonotonicRaw>;
using Stats = BasicStats<MonotonicRaw>;

/**
* @brief default constructor.
Expand Down Expand Up @@ -155,9 +155,9 @@ namespace join
class Rdtsc
{
public:
using Duration = std::chrono::nanoseconds;
using Duration = std::chrono::nanoseconds;
using TimePoint = std::chrono::time_point<NanoClock>;
using Stats = BasicStats<Rdtsc>;
using Stats = BasicStats<Rdtsc>;

/**
* @brief default constructor.
Expand Down Expand Up @@ -225,7 +225,7 @@ namespace join
::clock_gettime (CLOCK_MONOTONIC, &t1);
const uint64_t c1 = readCycles ();

const int64_t ns = (t1.tv_sec - t0.tv_sec) * 1'000'000'000LL + (t1.tv_nsec - t0.tv_nsec);
const int64_t ns = (t1.tv_sec - t0.tv_sec) * 1'000'000'000LL + (t1.tv_nsec - t0.tv_nsec);
const uint64_t cycles = c1 - c0;

cycleToNs () = (static_cast<uint64_t> (ns) << 32) / cycles;
Expand Down
4 changes: 2 additions & 2 deletions core/include/join/condition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace join
bool timedWait (Lock& lock, std::chrono::duration<Rep, Period> timeout)
{
struct timespec ts = toTimespec (std::chrono::steady_clock::now () + timeout);
int err = pthread_cond_timedwait (&_handle, lock.mutex ()->handle (), &ts);
int err = pthread_cond_timedwait (&_handle, lock.mutex ()->handle (), &ts);
if (err != 0)
{
lastError = std::error_code (err, std::generic_category ());
Expand Down Expand Up @@ -241,7 +241,7 @@ namespace join
bool timedWait (ScopedLock<SharedMutex>& lock, std::chrono::duration<Rep, Period> timeout)
{
struct timespec ts = toTimespec (std::chrono::steady_clock::now () + timeout);
int err = pthread_cond_timedwait (&_handle, lock.mutex ()->handle (), &ts);
int err = pthread_cond_timedwait (&_handle, lock.mutex ()->handle (), &ts);
if (err != 0)
{
lastError = std::error_code (err, std::generic_category ());
Expand Down
24 changes: 12 additions & 12 deletions core/include/join/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ namespace join
, _protocol (protocol.protocol ())
{
struct sockaddr_nl* nl = reinterpret_cast<struct sockaddr_nl*> (&this->_addr);
nl->nl_pid = pid;
nl->nl_groups = groups;
nl->nl_pid = pid;
nl->nl_groups = groups;
}

/**
Expand Down Expand Up @@ -697,16 +697,16 @@ namespace join
if (ip.family () == AF_INET6)
{
struct sockaddr_in6* sa = reinterpret_cast<struct sockaddr_in6*> (&this->_addr);
sa->sin6_family = AF_INET6;
sa->sin6_port = htons (port);
sa->sin6_family = AF_INET6;
sa->sin6_port = htons (port);
memcpy (&sa->sin6_addr, ip.addr (), ip.length ());
sa->sin6_scope_id = ip.scope ();
}
else
{
struct sockaddr_in* sa = reinterpret_cast<struct sockaddr_in*> (&this->_addr);
sa->sin_family = AF_INET;
sa->sin_port = htons (port);
sa->sin_family = AF_INET;
sa->sin_port = htons (port);
memcpy (&sa->sin_addr, ip.addr (), ip.length ());
}
}
Expand Down Expand Up @@ -742,14 +742,14 @@ namespace join
if (protocol.family () == AF_INET6)
{
struct sockaddr_in6* sa = reinterpret_cast<struct sockaddr_in6*> (&this->_addr);
sa->sin6_family = AF_INET6;
sa->sin6_port = htons (port);
sa->sin6_family = AF_INET6;
sa->sin6_port = htons (port);
}
else
{
struct sockaddr_in* sa = reinterpret_cast<struct sockaddr_in*> (&this->_addr);
sa->sin_family = AF_INET;
sa->sin_port = htons (port);
sa->sin_family = AF_INET;
sa->sin_port = htons (port);
}
}

Expand Down Expand Up @@ -780,14 +780,14 @@ namespace join
if (ip.family () == AF_INET6)
{
struct sockaddr_in6* sa = reinterpret_cast<struct sockaddr_in6*> (&this->_addr);
sa->sin6_family = AF_INET6;
sa->sin6_family = AF_INET6;
memcpy (&sa->sin6_addr, ip.addr (), ip.length ());
sa->sin6_scope_id = ip.scope ();
}
else
{
struct sockaddr_in* sa = reinterpret_cast<struct sockaddr_in*> (&this->_addr);
sa->sin_family = AF_INET;
sa->sin_family = AF_INET;
memcpy (&sa->sin_addr, ip.addr (), ip.length ());
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/include/join/ipaddress.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ namespace std
{
size_t operator() (const join::IpAddress& ipAddress) const noexcept
{
size_t h = 0;
size_t h = 0;
const uint8_t* bytes = reinterpret_cast<const uint8_t*> (ipAddress.addr ());
for (socklen_t i = 0; i < ipAddress.length (); ++i)
{
Expand Down
28 changes: 14 additions & 14 deletions core/include/join/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ namespace join
*/
explicit LocalMem (uint64_t size)
{
long sc = sysconf (_SC_PAGESIZE);
long sc = sysconf (_SC_PAGESIZE);
uint64_t pageSize = (sc > 0) ? static_cast<uint64_t> (sc) : _defaultPageSize;
_size = (size + pageSize - 1) & ~(pageSize - 1);
_size = (size + pageSize - 1) & ~(pageSize - 1);

create ();
}
Expand All @@ -164,7 +164,7 @@ namespace join
, _ptr (other._ptr)
{
other._size = 0;
other._ptr = nullptr;
other._ptr = nullptr;
}

/**
Expand All @@ -177,10 +177,10 @@ namespace join
cleanup ();

_size = other._size;
_ptr = other._ptr;
_ptr = other._ptr;

other._size = 0;
other._ptr = nullptr;
other._ptr = nullptr;

return *this;
}
Expand Down Expand Up @@ -325,9 +325,9 @@ namespace join
explicit ShmMem (uint64_t size, const std::string& name)
: _name (name)
{
long sc = sysconf (_SC_PAGESIZE);
long sc = sysconf (_SC_PAGESIZE);
uint64_t pageSize = (sc > 0) ? static_cast<uint64_t> (sc) : _defaultPageSize;
_size = (size + pageSize - 1) & ~(pageSize - 1);
_size = (size + pageSize - 1) & ~(pageSize - 1);

if (_size > static_cast<uint64_t> (std::numeric_limits<off_t>::max ()))
{
Expand Down Expand Up @@ -361,8 +361,8 @@ namespace join
, _fd (other._fd)
{
other._size = 0;
other._ptr = nullptr;
other._fd = -1;
other._ptr = nullptr;
other._fd = -1;
}

/**
Expand All @@ -376,12 +376,12 @@ namespace join

_size = other._size;
_name = std::move (other._name);
_ptr = other._ptr;
_fd = other._fd;
_ptr = other._ptr;
_fd = other._fd;

other._size = 0;
other._ptr = nullptr;
other._fd = -1;
other._ptr = nullptr;
other._fd = -1;

return *this;
}
Expand Down Expand Up @@ -492,7 +492,7 @@ namespace join
if ((_fd == -1) && (errno == EEXIST))
{
created = false;
_fd = ::shm_open (_name.c_str (), O_RDWR | O_CLOEXEC, 0644);
_fd = ::shm_open (_name.c_str (), O_RDWR | O_CLOEXEC, 0644);
}

if (_fd == -1)
Expand Down
Loading
Loading