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
int length(char *str) { | |
int s = 0; | |
for (; *str; ++str) ++s; | |
return s; | |
} | |
char *reverse(char *str) { | |
int size = length(str); | |
for (int i = 0; i < size / 2; ++i) { | |
str[i] ^= str[size - i - 1]; |
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
class Printer : public Theron::Actor | |
{ | |
public: | |
// Constructor, passes the framework to the baseclass. | |
Printer(Theron::Framework &framework) : Theron::Actor(framework) | |
{ | |
// Register the message handler. | |
RegisterHandler(this, &Printer::Print); | |
} |
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
package lichecker | |
import scala.concurrent._ | |
import scala.concurrent.duration.Duration | |
import ExecutionContext.Implicits.global | |
import com.codemacro.AsyncTask | |
object FutureList { | |
def run[T, T2](args: List[T], fn: => T => T2, max: Int): List[T2] = { |
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
$('#container').highcharts({ | |
chart: { | |
zoomType: 'x' | |
}, | |
title: { | |
text: 'service latency sample' | |
}, | |
subtitle: { | |
text: document.ontouchstart === undefined ? | |
'Click and drag in the plot area to zoom in' : |
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
_status : | |
HANGUP, // nothing to do | |
INCING, // increasing threads | |
DECING, // decreasing threads | |
manager_thread_proc { | |
while (_run) { | |
CondtionLock guard(ctrlCond); |
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 deflocal(name, ret, body) \ | |
struct name { \ | |
ret operator() body \ | |
} | |
#define callocal(name) name() | |
int main() { | |
// example | |
deflocal(hello, char*, (const char *from, const char *to) { |
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
all: | |
g++ -o thread -g -Wall -lpthread -ldl thread.cpp -DTEST_DTV_OVERFLOW | |
g++ -rdynamic -shared -fPIC dso_shared.cc -o shared.so | |
mkdir -p so | |
for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19; do cp shared.so so/shared-$$i.so; done | |
clean: | |
rm *.so so/*.so |
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 <stdio.h> | |
#include <string> | |
#include <map> | |
#include <vector> | |
#include <list> | |
void ds_str_i(void *p) { | |
char **raw = (char**)p; | |
char *s = *raw; | |
size_t len = *(size_t*)(s - sizeof(size_t) * 3); |
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
class Entity { | |
public: | |
enum { CLIENT, SERVER }; | |
Entity(const CGUID &id, int type, const std::string &brief); | |
// send text to this entity, this function will preprocess `text` | |
bool Send(const std::string &text); | |
private: |
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
// test.cpp : 定义控制台应用程序的入口点。 | |
// | |
#include <stdio.h> | |
#include <vector> | |
#include <string> | |
#include <assert.h> | |
struct OpCode { | |
/* 0: indicate `*' operator, 1: string match */ |
OlderNewer