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
Based on the pseudocode sample above, a `next/last/redo` could be executed on the second try, | |
without being executed in the first try, for *at least* the following reasons: | |
1. Initial transaction setup caused a retry with an unconditional `next/last/redo` in the body of the coderef | |
2. Some action in the coderef, before an unconditional `next/last/redo` caused a retry. | |
3. An unexpected or undesirable situation after a *skipped, conditional* `next/last/redo` causes a retry | |
(like optimistic locking failure). On the second try, conditions have changed (e.g. modification of data | |
in the database) and this changes the path taken by the code, triggering the *conditional* `next/last/redo`, | |
that wasn't triggered on the first try, due to different conditions in that run. |
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
#!/usr/bin/perl | |
use strict; # make sure $PWD is in your PERL5LIB | |
# no warnings! | |
use tx_exec qw(tx_exec); | |
tx_exec ("normal", sub { return "foobar"; }); | |
tx_exec ("die", sub { die "barbaz\n"; }); | |
tx_exec ("last", sub { last; }); |
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
import inspect | |
import ctypes | |
from time import sleep | |
from threading import Thread | |
def _async_raise(tid, exctype): | |
"""raises the exception, performs cleanup if needed""" | |
if not inspect.isclass(exctype): | |
exctype = type(exctype) | |
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(exctype)) |
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
$ cat x.cc | |
#include<type_traits> | |
#include<utility> | |
using namespace std; | |
struct T { | |
T() = default; | |
T(const T&) {} | |
}; | |
static_assert(is_move_constructible<T>(), ""); | |
T a; |
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
#include <utility> | |
#include <iostream> | |
using namespace std; | |
struct Explicit { | |
// prints whether the containing class's move or copy constructor was called | |
// in practice this would be the expensive vector<string> | |
string owner; | |
Explicit(string owner) : owner(owner) {}; | |
Explicit(const Explicit& o) { cout << o.owner << " is actually copying\n"; } |
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
#define IMPLICIT_DELETE_MEMBER 0 | |
#define DEFAULT_KEYWORD_INSIDE 0 | |
#include <utility> | |
#include <iostream> | |
struct Explicit { | |
Explicit() = default; | |
Explicit(const Explicit&) { std::cout<<"Explicit-Copy called\n"; } | |
Explicit(Explicit&&) noexcept { std::cout<<"Explicit-Move called\n"; } |
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
#include <iostream> | |
#include <vector> | |
#include <cstdio> | |
#include <unistd.h> | |
#include <pthread.h> | |
#include <termios.h> | |
using std::cout; | |
using std::getchar; |
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
public class User { | |
public String[] usernames; | |
public User(String[] names) { | |
usernames = names; | |
} | |
public String[] getUsernames() { | |
return usernames; | |
} |
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
import java.util.ArrayList; | |
import java.util.Collection; | |
import java.util.HashSet; | |
import java.util.Vector; | |
interface Wrapped<T> { | |
void commonWrappedMethod(); | |
} | |
class Wrapped1<T> implements Wrapped<T> { |
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
""" | |
Demonstrates creating windows or views of two-dimensional arrays, in two ways: | |
* Cutting off parts of window that is outside | |
* Continuing windows on the opposite side (circular sliding) | |
'numpy' is a very useful numerical library for python which *already* supports | |
creating windows/views (actually sub-arrays, for multidimensional arrays). This | |
code demonstrates how to "wrap" such an underlying implementation to provide | |
specialized functionality. |
NewerOlder