Peter Johnson
1a7a0db1ff
wpiutil: Change uv::AsyncFunction to use promise/future.
...
This allows the called function to pass along the promise to another
asynchronous callback.
To avoid memory allocations, add a home-rolled, simplified, non-allocating
version of std::promise and std::future as wpi::promise and wpi::future.
2018-10-16 09:40:59 -07:00
Peter Johnson
c7118f8ade
wpiutil: Signal: Don't use std::forward when calling ( #1371 )
...
This causes a std::move of objects that are both moveable and copyable.
2018-10-16 00:39:16 -07:00
Peter Johnson
613d5eda0d
wpiutil: SafeThread: join on thread exit ( #1357 )
...
This can be conditionally disabled (for cases like JNI callbacks where the JVM
may block callbacks into it during shutdown).
2018-10-06 15:17:13 -07:00
Peter Johnson
18c8cce6a7
SafeThread: Avoid use-after-free risk in thread shutdown ( #1355 )
...
Use shared_ptr to keep data alive until the thread has terminated.
2018-10-05 16:32:43 -07:00
Peter Johnson
36000ddb36
wpiutil: uv::Loop: Store the thread ID of the loop
2018-10-05 13:32:51 -07:00
Peter Johnson
de6d6c9a5c
wpiutil: EventLoopRunner: Allow getting the loop shared_ptr.
2018-10-05 13:32:51 -07:00
Peter Johnson
6d99c0ac6c
wpiutil: EventLoopRunner: Remove extraneous wpi namespace qualifier
2018-10-05 13:32:51 -07:00
Peter Johnson
40a9fc44ff
wpiutil: uv::Poll: add reuse functionality
2018-10-05 13:32:51 -07:00
Tyler Veness
8b1274d744
Replace typedefs in C++ with using declarations ( #1339 )
...
These are more readable than typedefs. C headers were left alone.
2018-09-26 00:09:25 -07:00
Tyler Veness
26c33a9a56
Remove priority_condition_variable ( #1337 )
...
Make wpi::condition_variable typedef to std::condition_variable_any if
wpi::mutex typedefs to priority_mutex.
priority_condition_variable was originally intended as a copy of
std::condition_variable_any that also returned the internal handle like
std::condition_variable. This was needed because NetComm required a
pthread_cond_t. We no longer use it anywhere.
Its args were specialized for priority_mutex, but
std::condition_variable_any supports this and more through
templatization.
2018-09-25 21:38:52 -07:00
Peter Johnson
c8482cd6d2
wpiutil: Add WebSocket implementation ( #1186 )
...
This is a RFC 6455 compliant implementation with both client and server support.
2018-08-24 20:54:23 -07:00
Peter Johnson
d6d5321828
wpiutil UidVector: Implement clear() and forward iterator ( #1293 )
...
The forward iterator only iterates over "live" elements.
Also add a couple of unit tests for UidVector.
2018-08-24 20:39:57 -07:00
Peter Johnson
8d91343bf5
wpiutil spinlock.h: Include STL mutex for convenience ( #1292 )
...
The STL mutex header defines classes like lock_guard and unique_lock.
2018-08-24 20:39:20 -07:00
Peter Johnson
8d8f120cc3
EventLoopRunner: Use AsyncFunction
2018-08-20 22:21:53 -07:00
Peter Johnson
57490e0002
Add uv::AsyncFunction to do a roundtrip function call to a uv::Async
...
This optionally blocks to wait for a return value.
2018-08-20 22:21:53 -07:00
Peter Johnson
1de1900dbb
Change uv::Async to accept data parameters
...
This is a breaking change as it makes Async a template (e.g. Async<> must
be used instead of just Async). When data parameters are provided, an
internal mutex and vector is used to hold the parameter packs until the loop
runs.
2018-08-20 22:21:53 -07:00
Peter Johnson
4a3e43d4a7
Add HttpMultipartScanner ( #1197 )
...
This is a non-blocking version of FindMultipartBoundary.
2018-08-20 22:00:54 -07:00
Peter Johnson
9e37ee13de
Add wpi::HttpServerConnection and an example of its use ( #1281 )
2018-08-20 13:11:39 -07:00
Peter Johnson
83cfb8b19f
UrlParser: fix Has() functions ( #1283 )
2018-08-19 17:25:42 -07:00
Peter Johnson
46ae19d082
wpiutil: Add a mutex-compatible spinlock implementation ( #1272 )
...
Note this is only faster than mutex if compiler optimization is enabled.
2018-08-19 01:01:10 -07:00
Peter Johnson
77124a229e
Twine: disable part of isValid() that causes spurious warnings ( #1271 )
2018-08-16 19:35:40 -07:00
Peter Johnson
9408fd5176
Add Doxygen comments for namespaces ( #1245 )
2018-07-29 12:49:28 -07:00
Peter Johnson
826ed7fe3c
SmallPtrSet: Fix makeIterator
2018-07-28 17:34:42 -07:00
Peter Johnson
8aac46542d
Add a SimpleBufferPool for uv::Buffer ( #1215 )
...
Buffers are reused on a regular basis in many use cases.
2018-07-25 00:58:54 -07:00
Peter Johnson
c25d48fd0c
HttpParser: Add Reset() function ( #1210 )
...
This allows reuse of the HttpParser object for multiple requests.
2018-07-22 19:41:23 -07:00
Peter Johnson
31ced30c1e
HttpParser: Change Execute() to return StringRef ( #1209 )
...
This is more user-friendly than returning the number of parsed bytes.
2018-07-22 15:07:22 -07:00
Peter Johnson
5bf5821138
Cleanup docs in uv::Stream and uv::Tcp ( #1207 )
2018-07-22 13:01:14 -07:00
Peter Johnson
eed28a5852
Add sockaddr_in overloads for uv::Tcp and uv::Udp ( #1206 )
...
These help avoid the need for reinterpret_casts in common use cases.
2018-07-22 13:01:00 -07:00
Peter Johnson
435e026c08
uv::Loop: Add user-defined data ( #1205 )
2018-07-22 13:00:47 -07:00
Peter Johnson
739267d36d
Add Reuse function to uv::Tcp ( #1208 )
...
This allows reusing the Tcp object in cases when the connection errors out.
2018-07-22 12:31:50 -07:00
Peter Johnson
70b0d7cb03
UDPClient: Add receive functionality ( #1204 )
2018-07-21 23:49:16 -07:00
Peter Johnson
caa03d23a3
Make JxArrayRef less error-prone for jxArray ( #1190 )
...
Add a length-taking overload so that if a length happens to be provided for
a jarray, the direct byte buffer overload is not used.
2018-07-17 20:19:49 -07:00
Peter Johnson
297863b17a
Add HttpParser and UrlParser C++ wrappers for http_parser.
2018-07-17 02:24:56 -07:00
Peter Johnson
1992b67ee3
Import nodejs/http-parser.
...
Upstream version: 5b76466c6b9063e2c5982423962a16f7319c81f8
2018-07-17 02:24:56 -07:00
Peter Johnson
e2314f3528
wpiutil: Add C++ libuv wrappers ( #1166 )
...
- Provide an EventLoopRunner to run uv::Loop on a separate thread.
- Add raw_ostream wrapper for uv::Buffer.
2018-07-17 01:06:24 -07:00
Peter Johnson
de5d7d3c17
Only use priority_mutex on RoboRIO by default. ( #1172 )
...
On all Linux platforms it can be specifically requested by defining
WPI_USE_PRIORITY_MUTEX.
2018-07-03 20:35:07 -07:00
Peter Johnson
70960b0251
Signal: rename Signal to Signal_mt and Signal_st to Signal.
...
The single-threaded version is fine for most of the use cases we're planning
on, and is half the size on most platforms.
2018-06-30 00:21:09 -07:00
Peter Johnson
c8afe9bc2f
Signal: Optimize to use plain std::function.
...
This optimizes the common case of a single simple callback (e.g. std::function
or lambda) so no additional allocation is required. As a Connection return
value is not possible in this case, provide a separate connect_connection()
function to provide that.
2018-06-30 00:21:09 -07:00
Peter Johnson
876c650471
wpiutil: Add a signal-slot implementation. ( #1163 )
...
Imported from https://github.com/palacaze/sigslot
Classes were renamed from lowercase_me to UppercaseMe style, primarily
to avoid conflicting with the C standard library "signal" function. They
were also moved to the "wpi::sig" namespace.
2018-06-27 23:01:17 -07:00
Peter Johnson
ea7d11b1db
Twine: Make isNull() public. ( #1162 )
...
This makes it possible to pass "null" Twines and detect it in the callee.
2018-06-23 16:13:50 -07:00
Peter Johnson
6aebba5452
Import MapVector from LLVM. ( #1128 )
2018-06-03 08:39:14 -07:00
Tyler Veness
8c680a26f8
Moved C++ comments from source files to headers ( #1111 )
...
Also sorted functions in C++ sources to match order in related headers.
2018-05-31 20:47:15 -07:00
Thad House
307da3ad2d
Simplify allocation of JNI global classes and exceptions ( #1110 )
...
Helps ensure they get freed properly (We have had a few cases before where this wasn't the case).
2018-05-29 15:44:16 -07:00
Peter Johnson
a2ecb1027a
Update LLVM to latest upstream. ( #1080 )
...
Also change header guards to WPI header guards.
Remove StringRef::c_str() customization, replacing the handful of uses with Twine or SmallString.
TCPStream: Include errno.h and make Windows includes lowercase for consistency.
Upstream LLVM version: eb4186cca7924fb1706357545311a2fa3de40c59
2018-05-22 23:31:08 -07:00
Peter Johnson
f8ed48af98
Update json from upstream version 3.1.2.
...
This adds support for ubjson and makes a number of bugfixes.
Binary input and output have switched from strings to uint8_t arrays.
2018-05-15 22:31:35 -07:00
Peter Johnson
c274d1790f
StringRef: Add comparison operators against const char*.
2018-05-15 22:31:35 -07:00
Peter Johnson
6699f86361
Make most StringRef functions noexcept.
2018-05-15 22:31:35 -07:00
Peter Johnson
c2b1ed3edd
ArrayRef: Add value_type typedef like std containers.
2018-05-15 22:31:35 -07:00
Peter Johnson
2c27ad073a
raw_istream enhancements.
2018-05-15 22:31:35 -07:00
Peter Johnson
31bb55c319
Add std::vector and unsigned variants of raw_ostream.
2018-05-15 22:31:35 -07:00