This file contains hidden or 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
export function handleAction (action) { | |
const args = action.payload || [] | |
switch (action.type) { | |
case DO_SOMETHING: | |
return doSomething(...args) | |
default: | |
break | |
} | |
} |
This file contains hidden or 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
import { Namespace } from '../core/Namespace' | |
export const internal = Namespace('Semaphore') | |
class Task { | |
constructor(semaphore, callback) { | |
const promises = [ | |
new Promise((resolve, reject) => { | |
this.resolve = resolve | |
this.reject = reject |
This file contains hidden or 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
export function Namespace(name) { | |
const symbol = Symbol(name) | |
return function namespace(object, init = () => ({})) { | |
if (object[symbol] === undefined) { | |
object[symbol] = init() | |
} | |
return object[symbol] | |
} | |
} |
This file contains hidden or 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
class Multiplier { | |
constructor(value) { | |
const coefficient = value | |
return { | |
by(other) { | |
return other * coefficient | |
}, | |
} | |
} |
This file contains hidden or 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
class Base { | |
constructor() { | |
const privateVariable | |
this._protectedVariable | |
this.publicVariable | |
function privateFunction() {} | |
} | |
_protectedFunction() {} |
This file contains hidden or 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
function Base() { | |
var privateVariable; | |
this._protectedVariable; | |
this.publicVariable; | |
function privateFunction() {} | |
} | |
Base.prototype._protectedFunction = function () {}; | |
Base.prototype.publicFunction = function () {}; |
This file contains hidden or 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
import Namespace from '../core/Namespace' | |
const self = undefined | |
const internal = Namespace() | |
class Task { | |
constructor(semaphore, callback) { | |
const promises = [ | |
new Promise((resolve, reject) => { | |
this.resolve = resolve |
This file contains hidden or 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
#include <array> | |
#include "ratio.h" | |
template < | |
class A_, class B_, class C_, | |
class D_, class E_, class F_, | |
class G_, class H_, class I_ | |
> | |
struct RatioMatrix { |
This file contains hidden or 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
#include <ratio> | |
namespace detail { | |
template <class... Args> | |
struct RatioAdd; | |
template <class R1, class R2> | |
struct RatioAdd<R1, R2> { | |
using Type = std::ratio_add<R1, R2>; |
This file contains hidden or 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
// Given | |
const auto size = ...; | |
auto begin = ...; | |
std::list<std::future<void>> futures; | |
const auto concurrency = std::thread::hardware_concurrency(); | |
const auto partition = std::imaxdiv(size, concurrency); | |
for (int i{}; i < concurrency; ++i) { | |
const auto end = begin + partition.quot + (i < partition.rem); | |
futures.emplace_back(std::async([this, begin, end]() { |
NewerOlder