iodine 0.6.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +4 -4
- data/SPEC-Websocket-Draft.md +3 -6
- data/bin/mustache.rb +128 -0
- data/examples/test_template.mustache +16 -0
- data/ext/iodine/fio.c +9397 -0
- data/ext/iodine/fio.h +4723 -0
- data/ext/iodine/fio_ary.h +353 -54
- data/ext/iodine/fio_cli.c +351 -361
- data/ext/iodine/fio_cli.h +84 -105
- data/ext/iodine/fio_hashmap.h +70 -16
- data/ext/iodine/fio_json_parser.h +35 -24
- data/ext/iodine/fio_siphash.c +104 -4
- data/ext/iodine/fio_siphash.h +18 -2
- data/ext/iodine/fio_str.h +1218 -0
- data/ext/iodine/fio_tmpfile.h +1 -1
- data/ext/iodine/fiobj.h +13 -8
- data/ext/iodine/fiobj4sock.h +6 -8
- data/ext/iodine/fiobj_ary.c +107 -17
- data/ext/iodine/fiobj_ary.h +36 -4
- data/ext/iodine/fiobj_data.c +146 -127
- data/ext/iodine/fiobj_data.h +25 -23
- data/ext/iodine/fiobj_hash.c +7 -7
- data/ext/iodine/fiobj_hash.h +6 -5
- data/ext/iodine/fiobj_json.c +20 -17
- data/ext/iodine/fiobj_json.h +5 -5
- data/ext/iodine/fiobj_mem.h +71 -0
- data/ext/iodine/fiobj_mustache.c +310 -0
- data/ext/iodine/fiobj_mustache.h +40 -0
- data/ext/iodine/fiobj_numbers.c +199 -94
- data/ext/iodine/fiobj_numbers.h +7 -7
- data/ext/iodine/fiobj_str.c +142 -333
- data/ext/iodine/fiobj_str.h +65 -55
- data/ext/iodine/fiobject.c +49 -11
- data/ext/iodine/fiobject.h +40 -39
- data/ext/iodine/http.c +382 -190
- data/ext/iodine/http.h +124 -80
- data/ext/iodine/http1.c +99 -127
- data/ext/iodine/http1.h +5 -5
- data/ext/iodine/http1_parser.c +3 -2
- data/ext/iodine/http1_parser.h +2 -2
- data/ext/iodine/http_internal.c +14 -12
- data/ext/iodine/http_internal.h +25 -19
- data/ext/iodine/iodine.c +37 -18
- data/ext/iodine/iodine.h +4 -0
- data/ext/iodine/iodine_caller.c +9 -2
- data/ext/iodine/iodine_caller.h +2 -0
- data/ext/iodine/iodine_connection.c +82 -117
- data/ext/iodine/iodine_defer.c +57 -50
- data/ext/iodine/iodine_defer.h +0 -1
- data/ext/iodine/iodine_fiobj2rb.h +4 -2
- data/ext/iodine/iodine_helpers.c +4 -4
- data/ext/iodine/iodine_http.c +25 -32
- data/ext/iodine/iodine_json.c +2 -1
- data/ext/iodine/iodine_mustache.c +423 -0
- data/ext/iodine/iodine_mustache.h +6 -0
- data/ext/iodine/iodine_pubsub.c +48 -153
- data/ext/iodine/iodine_pubsub.h +5 -4
- data/ext/iodine/iodine_rack_io.c +7 -5
- data/ext/iodine/iodine_store.c +16 -13
- data/ext/iodine/iodine_tcp.c +26 -34
- data/ext/iodine/mustache_parser.h +1085 -0
- data/ext/iodine/redis_engine.c +740 -646
- data/ext/iodine/redis_engine.h +13 -15
- data/ext/iodine/resp_parser.h +11 -5
- data/ext/iodine/websocket_parser.h +13 -13
- data/ext/iodine/websockets.c +240 -393
- data/ext/iodine/websockets.h +52 -113
- data/lib/iodine.rb +1 -1
- data/lib/iodine/mustache.rb +140 -0
- data/lib/iodine/version.rb +1 -1
- metadata +15 -28
- data/ext/iodine/defer.c +0 -566
- data/ext/iodine/defer.h +0 -148
- data/ext/iodine/evio.c +0 -26
- data/ext/iodine/evio.h +0 -161
- data/ext/iodine/evio_callbacks.c +0 -26
- data/ext/iodine/evio_epoll.c +0 -251
- data/ext/iodine/evio_kqueue.c +0 -194
- data/ext/iodine/facil.c +0 -2325
- data/ext/iodine/facil.h +0 -616
- data/ext/iodine/fio_base64.c +0 -277
- data/ext/iodine/fio_base64.h +0 -71
- data/ext/iodine/fio_llist.h +0 -257
- data/ext/iodine/fio_mem.c +0 -675
- data/ext/iodine/fio_mem.h +0 -143
- data/ext/iodine/fio_random.c +0 -248
- data/ext/iodine/fio_random.h +0 -45
- data/ext/iodine/fio_sha1.c +0 -362
- data/ext/iodine/fio_sha1.h +0 -107
- data/ext/iodine/fio_sha2.c +0 -842
- data/ext/iodine/fio_sha2.h +0 -169
- data/ext/iodine/pubsub.c +0 -867
- data/ext/iodine/pubsub.h +0 -221
- data/ext/iodine/sock.c +0 -1366
- data/ext/iodine/sock.h +0 -566
- data/ext/iodine/spnlock.inc +0 -111
data/ext/iodine/spnlock.inc
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
#ifndef H_SPNLOCK_H
|
|
2
|
-
#define H_SPNLOCK_H
|
|
3
|
-
/*
|
|
4
|
-
Copyright: Boaz Segev, 2016-2017
|
|
5
|
-
License: MIT
|
|
6
|
-
|
|
7
|
-
Feel free to copy, use and enjoy according to the license provided.
|
|
8
|
-
*/
|
|
9
|
-
/* *****************************************************************************
|
|
10
|
-
spinlock / sync for tasks
|
|
11
|
-
***************************************************************************** */
|
|
12
|
-
#if defined(__unix__) || defined(__APPLE__) || defined(__linux__)
|
|
13
|
-
#ifndef _GNU_SOURCE
|
|
14
|
-
#define _GNU_SOURCE
|
|
15
|
-
#endif
|
|
16
|
-
#include <time.h>
|
|
17
|
-
#endif /* __unix__ */
|
|
18
|
-
#include <stdlib.h>
|
|
19
|
-
|
|
20
|
-
/* manage the way threads "wait" for the lock to release */
|
|
21
|
-
#if defined(__unix__) || defined(__APPLE__) || defined(__linux__)
|
|
22
|
-
/* nanosleep seems to be the most effective and efficient reschedule */
|
|
23
|
-
#define reschedule_thread() \
|
|
24
|
-
{ \
|
|
25
|
-
const struct timespec tm = {.tv_nsec = 1}; \
|
|
26
|
-
nanosleep(&tm, NULL); \
|
|
27
|
-
}
|
|
28
|
-
#define throttle_thread(micosec) \
|
|
29
|
-
{ \
|
|
30
|
-
const struct timespec tm = {.tv_nsec = (micosec & 0xfffff), \
|
|
31
|
-
.tv_sec = (micosec >> 20)}; \
|
|
32
|
-
nanosleep(&tm, NULL); \
|
|
33
|
-
}
|
|
34
|
-
#else /* no effective rescheduling, just spin... */
|
|
35
|
-
#define reschedule_thread()
|
|
36
|
-
#define throttle_thread(micosec)
|
|
37
|
-
#endif
|
|
38
|
-
|
|
39
|
-
/** locks use a single byte */
|
|
40
|
-
typedef volatile unsigned char spn_lock_i;
|
|
41
|
-
|
|
42
|
-
/** The initail value of an unlocked spinlock. */
|
|
43
|
-
#define SPN_LOCK_INIT 0
|
|
44
|
-
|
|
45
|
-
/* C11 Atomics are defined? */
|
|
46
|
-
#if defined(__ATOMIC_RELAXED)
|
|
47
|
-
#define SPN_LOCK_BUILTIN(...) __atomic_exchange_n(__VA_ARGS__, __ATOMIC_SEQ_CST)
|
|
48
|
-
/** An atomic addition operation */
|
|
49
|
-
#define spn_add(...) __atomic_add_fetch(__VA_ARGS__, __ATOMIC_SEQ_CST)
|
|
50
|
-
/** An atomic subtraction operation */
|
|
51
|
-
#define spn_sub(...) __atomic_sub_fetch(__VA_ARGS__, __ATOMIC_SEQ_CST)
|
|
52
|
-
|
|
53
|
-
/* Select the correct compiler builtin method. */
|
|
54
|
-
#elif defined(__has_builtin)
|
|
55
|
-
|
|
56
|
-
#if __has_builtin(__sync_fetch_and_or)
|
|
57
|
-
#define SPN_LOCK_BUILTIN(...) __sync_fetch_and_or(__VA_ARGS__)
|
|
58
|
-
/** An atomic addition operation */
|
|
59
|
-
#define spn_add(...) __sync_add_and_fetch(__VA_ARGS__)
|
|
60
|
-
/** An atomic subtraction operation */
|
|
61
|
-
#define spn_sub(...) __sync_sub_and_fetch(__VA_ARGS__)
|
|
62
|
-
|
|
63
|
-
#else
|
|
64
|
-
#error Required builtin "__sync_swap" or "__sync_fetch_and_or" missing from compiler.
|
|
65
|
-
#endif /* defined(__has_builtin) */
|
|
66
|
-
|
|
67
|
-
#elif __GNUC__ > 3
|
|
68
|
-
#define SPN_LOCK_BUILTIN(...) __sync_fetch_and_or(__VA_ARGS__)
|
|
69
|
-
/** An atomic addition operation */
|
|
70
|
-
#define spn_add(...) __sync_add_and_fetch(__VA_ARGS__)
|
|
71
|
-
/** An atomic subtraction operation */
|
|
72
|
-
#define spn_sub(...) __sync_sub_and_fetch(__VA_ARGS__)
|
|
73
|
-
|
|
74
|
-
#else
|
|
75
|
-
#error Required builtin "__sync_swap" or "__sync_fetch_and_or" not found.
|
|
76
|
-
#endif
|
|
77
|
-
|
|
78
|
-
/** returns 1 and 0 if the lock was successfully aquired (TRUE == FAIL). */
|
|
79
|
-
static inline int spn_trylock(spn_lock_i *lock) {
|
|
80
|
-
return SPN_LOCK_BUILTIN(lock, 1);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Releases a lock. */
|
|
84
|
-
static inline __attribute__((unused)) int spn_unlock(spn_lock_i *lock) {
|
|
85
|
-
return SPN_LOCK_BUILTIN(lock, 0);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** returns a lock's state (non 0 == Busy). */
|
|
89
|
-
static inline __attribute__((unused)) int spn_is_locked(spn_lock_i *lock) {
|
|
90
|
-
__asm__ volatile("" ::: "memory");
|
|
91
|
-
return *lock;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Busy waits for the lock. */
|
|
95
|
-
static inline __attribute__((unused)) void spn_lock(spn_lock_i *lock) {
|
|
96
|
-
while (spn_trylock(lock)) {
|
|
97
|
-
reschedule_thread();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
#if DEBUG_SPINLOCK
|
|
102
|
-
/** Busy waits for a lock, reports contention. */
|
|
103
|
-
#define spn_lock(lock) \
|
|
104
|
-
while (spn_trylock(lock)) { \
|
|
105
|
-
fprintf(stderr, "INFO: spinlock spin %s:%d\n", __FILE__, __LINE__); \
|
|
106
|
-
reschedule_thread(); \
|
|
107
|
-
}
|
|
108
|
-
#include <stdio.h>
|
|
109
|
-
#endif /* DEBUG */
|
|
110
|
-
|
|
111
|
-
#endif /* H_SPNLOCK_H */
|