Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am jmlvanre on github.
  • I am jmlvanre (https://keybase.io/jmlvanre) on keybase.
  • I have a public key whose fingerprint is 6184 2926 19CC 55CC 61BB 1300 73A0 5B74 C458 1178

To claim this, I am signing this object:

shared_ptr in a class hierarchy

class Stream {
  public:
  virtual ~Stream() {}
  protected:
  class Data {
    protected:
    Data() {}
    virtual ~Data() {}
class StreamImpl : public std::enable_shared_from_this {
  public:
  virtual ~StreamImpl() {}
  virtual Future<size_t> write(const std::string& data) = 0;
  private:
  std::shared_ptr<StreamImpl> self;
};

class SocketImpl : public StreamImpl {
class IP {
enum family {
INET,
INET6
};
virtual ~IP() {}
inline family getFamily() const {
return _family;
}
virtual setSockAddrIn(sockaddr_in& data) const = 0;
@jmlvanre
jmlvanre / template_storage
Created January 29, 2015 00:01
Templatized storage without forward declaration of types
#include <unordered_set>
/* Templatized storage without forward declaration of types. */
class TC {
public:
template<typename T>
class TM {
public:
virtual ~TM() { C->Part(this); }
protected:
@jmlvanre
jmlvanre / const_ref_to_temporary.md
Last active September 26, 2020 00:20
[Proposal] Const Reference to Temporary style-guide

Proposal:

We modify the style guide to disallow constant references to temporaries as a whole. This means disallowing both Case 1 and Case 2 below.

Background:

  • Case 1: Constant references to simple expression temporaries do extend the lifetime of the temporary till end of function scope:
    • a) Temporary returned by function:
    // See full example below.

T f(const char* s) { return T(s); }

@jmlvanre
jmlvanre / gcc_4_7_features.md
Last active August 29, 2015 14:18
New GCC Features 4.4 => 4.7
  • Range-based For Loop:
    • We can now write for loops as such:
    std::map<K, V> data;
    for (const std::pair<K, V>& pair : data) {}
    for (const auto& pair : data) {}
  • Explicit Virtual Override:
    • We can now introduce a safety measure on virtual function override so that if the base prototype changes, our program will no longer compile until the override definition has been changed to match. This is a great safety measure in a growing code base.
@jmlvanre
jmlvanre / mesos_c++_upgrade.md
Last active August 29, 2015 14:18
Mesos C++ Upgrade

Focus:

As the full c++11 feature set is rather extensive, we want to start the upgrade to c++11 with 3 main areas of focus:

  1. Lambdas
  2. Unrestricted Unions
  3. Move semantics

Lambdas:

  • Definition:
@jmlvanre
jmlvanre / lambda_style.md
Last active August 29, 2015 14:19
lambda style
auto lambda = [] () { return true };

auto lambda = [] () {
  ...;
};

socket.send([] () {
  ...;
@jmlvanre
jmlvanre / mesos-ssl.md
Last active August 29, 2015 14:23
Mesos SSL
layout
documentation

#Configuration There is currently only one implementation of the libprocess socket interface that supports SSL. This implementation uses libevent. Specifically it relies on the libevent-openssl library that wraps openssl.

After build Mesos 0.23.0 from source, assuming you have installed the required Dependencies, you can modify your configure line to enable SSL as follows: