Commit Graph

37 Commits

Author SHA1 Message Date
Peter Johnson
9f5fe63aaa Reuse dead connection slots.
This fixes a memory leak on multiple disconnect/reconnect of the same client.
2015-11-01 22:48:11 -08:00
Peter Johnson
03ee425e5f Add additional debug messages. 2015-11-01 22:48:11 -08:00
Peter Johnson
dd0e3e4abb Implement join with timeout (and detach).
Under certain situations (notably JNI shutdown), it's possible to get
deadlock when using thread join().  To avoid this, implement a timeout.
Normally we try to simply join the thread, but if it times out, we
detach the thread instead.
2015-10-09 23:50:01 -07:00
Peter Johnson
6d8e796932 Disable logging on static instance destruction.
This avoids possible deadlocks on exit when a logger callback exists.
2015-09-12 21:44:51 -07:00
Peter Johnson
f7e603c7db Add DEBUG4 message for messages received during client handshake. 2015-09-11 19:19:15 -07:00
Peter Johnson
953a2ce807 Implement keep-alives. 2015-09-08 23:17:11 -07:00
Peter Johnson
e1efb7364e Don't allow update intervals slower than 1 second. 2015-09-06 11:41:35 -07:00
Peter Johnson
7565207242 StartClient(): Make a local copy of server_name.
Previously we just held onto the const char* provided by the user.
This does not work in cases such as Java which provide a temporary
string.
2015-08-29 00:07:10 -07:00
Peter Johnson
b488cdd6ff Support immediate notify of connection listener.
Also only perform immediate notification to the callback actually
requesting the notification, not all existing callbacks.

Offset returned uids by 1 so uid=0 can be used to indicate immediate
notification.
2015-08-28 00:13:56 -07:00
Peter Johnson
2d1bc2f4c7 Uninline constructors to reduce GetInstance() inlined code size. 2015-08-19 21:49:18 -07:00
Peter Johnson
c6bed1f464 Dispatcher: Move several fixed initial values to header. 2015-08-19 21:16:44 -07:00
Peter Johnson
ca9ce0f3a3 Implement automatic persistent saves.
Also loads persistent file on server start.
2015-08-19 19:18:09 -07:00
Peter Johnson
8d7cdeabbf Implement remote procedure calls. 2015-08-13 21:32:16 -07:00
Peter Johnson
a86f65db1e Dispatcher: Implement transmit combining.
This handles most of the major cases, but not a loop of delete/assign, which
should be uncommon anyway.
2015-08-02 23:21:23 -07:00
Peter Johnson
e9073a3cc0 Implement notifiers.
The notifier thread is lazily started when the first notifier is added.
This avoids the extra thread/processing overhead when notifiers are not used.
2015-08-02 21:47:01 -07:00
Peter Johnson
538a19fd47 Implement GetConnections(). 2015-08-02 10:47:05 -07:00
Peter Johnson
84ff80710c Refactor TCP-specific pieces of Dispatcher. 2015-08-02 00:33:41 -07:00
Peter Johnson
6703968f73 Dispatcher: Fix shutdown order race.
We need to wait until after the dispatch and client/server threads have
been stopped before closing connections, as these threads can add connections.
2015-08-01 23:37:13 -07:00
Peter Johnson
b5274a495e Dispatcher: Don't call Storage::GetInstance() internally.
This makes it difficult to test.  Instead, store reference as member variable,
and populate it at constuction (with an alternate constructor available for
test purposes).
2015-08-01 11:15:04 -07:00
Peter Johnson
11508b77d1 Ensure initial synchronization is atomic. 2015-07-31 23:56:06 -07:00
Peter Johnson
c2eb4a766e Dispatcher: Provide some INFO-level connection messages. 2015-07-31 23:26:38 -07:00
Peter Johnson
3a71acec52 Automatically reconnect client.
Also clean up some condition variable handling to make it more robust.
2015-07-31 23:14:26 -07:00
Peter Johnson
a9af4589ac Don't send empty message lists from dispatch.
This terminates the write thread.
2015-07-31 22:49:43 -07:00
Peter Johnson
4356e313ec Add logging framework.
DEBUG messages are completely optimized out if NDEBUG is defined.
2015-07-31 22:41:26 -07:00
Peter Johnson
ead125555c Implement client/server handshaking. 2015-07-31 20:32:52 -07:00
Peter Johnson
138ebf5b4d Storage: generate messages rather than intermediate updates. 2015-07-31 13:21:19 -07:00
Peter Johnson
83be99e78c Immediately process incoming messages.
This required moving message processing into the Storage class.
2015-07-29 23:45:04 -07:00
Peter Johnson
5b5e3ae6aa Dispatcher: Start implementing processing of incoming messages. 2015-07-29 20:33:26 -07:00
Peter Johnson
b4c65dc210 Make global instance init thread-safe.
Use local statics except for Visual C++ < 2015.
2015-07-20 23:36:22 -07:00
Peter Johnson
6b2fb02bed Dispatcher: Don't in-place construct atomics.
Visual C++ 2013 doesn't support this.
2015-07-20 20:21:37 -07:00
Peter Johnson
8938a19810 Dispatcher: Avoid warning by using for(;;) instead of while(true). 2015-07-20 20:20:01 -07:00
Peter Johnson
158ae61811 Dispatcher::SetUpdateRate(): Explicitly convert to int. 2015-07-20 20:19:01 -07:00
Peter Johnson
c9260ea785 Change GetEntryTypeFunc to std::function.
Also implement it as a member function of Dispatcher.
2015-07-19 23:17:14 -07:00
Peter Johnson
9b7e265762 Continue implementing client. 2015-07-18 01:29:24 -07:00
Peter Johnson
412e8034de Start implementing client and server. 2015-07-17 22:39:36 -07:00
Peter Johnson
fcbd2751ba Provide C++ API. Move all classes to "nt" namespace.
The C API is now just simple wrappers around the C++ API.
2015-07-17 07:21:07 -07:00
Peter Johnson
56f1481c24 Add Dispatcher. 2015-07-16 22:55:50 -07:00