• Configure CMake to generate libredox.so and libredox_static.a, and have
    all examples use the dynamic library. This is how Redox should be used
    in practice, and greatly reduces the compilation time of the examples.
    
    Also renamed redox.[ch]pp to client.[ch]pp and created one master header
    redox.hpp for users to include. This header right now just includes
    client.hpp, command.hpp, and subscriber.hpp.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Make .free() on commands send a message over an async watcher to the
    event loop, just like adding commands. This gets rid of some very tough
    to find memory bugs. Combined .cancel() with .free(), so there is only
    one method to call, whether for synchronous commands or for looped
    commands.
    
    Also debug some horrible segfaults related to Subscriber. Something is
    odd with hiredis and subscriptions, need to ask them. It seems when we
    flood with commands it doesn't disconnect cleanly. Look for a way to
    wait until all commands are processed.
    Hayk Martirosyan authored
     
    Browse Dir »


  • Split up command into command, command_blocking, and command_looping.
    The original command no longer returns anything, which clarifies how it
    should be used in most cases. command_looping and command_blocking both
    return a command object.
    
    Also added a waiting CV to the Command object, though it is not used in
    command_blocking yet.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Now, there is only one callback for command(), and it returns a const
    reference to the Command object. The user is responsible for error
    checking using c.ok(), c.status(), and getting the reply with c.reply().
    This significantly cleans up the library code and the user code.
    
    Greatly refactored the data type specialization code in command.cpp.
    Hayk Martirosyan authored
     
    Browse Dir »

  • subscribe/psubscribe/unsubscribe/punsubscribe methods that keep track of
    subscribed topics to make sure we don't ask hiredis for bad things. It
    appears all crashes are eliminated, though no stress testing has been
    done.
    Hayk Martirosyan authored
     
    Browse Dir »

  • subscribe/unsubscribe/publish with proper and working callbacks. Guard
    added that throws an exception if a non-pubsub command is issued after a
    subscribe.
    
    Also removed all std:: prefixes from redox.cpp. Just made the decision
    for "using namespace std" there for readability. Not a header, of
    course.
    
    Also added another async watcher for breaking the loop, since ev_break
    doesn't actually do anything when called outside of an ev_run callback.
    Hayk Martirosyan authored
     
    Browse Dir »



  • Consolidated user callbacks into one, improved some logic.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Created an atomic_int connect_state that keeps track of not yet
    connected, connected, disconnected, and errors. Used to implement good
    error behavior when the server is down and you start() a Redox instance,
    or when the server goes down in the middle of running commands. Now,
    nothing should hang, but should return errors (or throw exceptions) when
    the server goes down.
    
    Also added hooks for a user connect/disconnect callback in the
    constructor, which is helpful for client programs.
    
    Added an example with three Redox clients in one thread.
    Hayk Martirosyan authored
     
    Browse Dir »



  • Created a pointer Command.rdx (Redox*) to allow commands
    to increment Redox.cmd_count, and simplify a couple of
    other things.
    
    Did a little bit of moving and renaming context objects,
    so the context is always .ctx and commands can always
    be called c.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Added Command<nullptr_t> which successfully returns NIL
    replies from Redis, with REDOX_OK. Also renamed constants
    from REDISX_ -> REDOX_.
    
    Moved a bunch of code from redox.cpp into command.cpp, where
    it logically makes more sense.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Move as much as possible into the .cpp file, and clean things up.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Found out that ev_timer watchers have a void* data that allows
    currying information to the libev callbacks! That means I could
    stick the Command* in there and completely get rid of the global
    timer_callbacks map that was needed before.
    
    Additionally, we can move ev_timer into the Command object instead
    of separately allocating it on the heap. Simplifies management.
    
    Implemented a synchronous loop speed test based on the latest
    and greatest command_blocking(). Happy to see it is around
    30k/s, which is 100% network delays.
    Hayk Martirosyan authored
     
    Browse Dir »
  • Several hours of multithreaded debugging to find a nasty extra
    ampersand. command_blocking() now returns a Command object with
    the value and status accessible through methods.
    
    Added the option to free memory or not for Command objects when
    command() is called. If free_memory = true, then the Command
    object is freed after the callback or error callback returns.
    If free_memory = false, then the user must call cmd->free().
    
    To implement this, we have to pass in a blank function to the
    freeObject entry in the hiredis redisReader, because otherwise
    it automatically frees memory. This was not cool for the blocking
    case.
    Hayk Martirosyan authored
     
    Browse Dir »

  • Implemented error callbacks for command(). Now, either the success
    or error callbacks are guaranteed to return for any command. Added
    constants for error types.
    
    Many improvements and fixes for memory management. Command objects
    keep track of pending replies and delete themselves when completed.
    
    Changed ReplyT value to remove the const and reference requirements.
    Now, you do command<ReplyT> and the callback should take a
    const ReplyT&, whatever the type is. Makes things more uniform.
    Hayk Martirosyan authored
     
    Browse Dir »


  • Hayk Martirosyan authored
     
    Browse Dir »
  • The event loop (now libev) now runs in a separate detached thread,
    which is abstracted away from the user, who only calls a nonblocking
    .start() method. This thread loops continously, alternating telling
    Redis about asynchronous commands ready to send, and running one
    iteration of the event loop, where all pending events are taken
    care of. This greatly simplifies the user code.
    
    Additionally, some clever tricker is implemented now to handle
    memory management well with the templated command types. The
    difficulty comes from the fact that we pass redis a void pointer
    only, and must retreive everything from that (so, we can't use
    shared_ptr for the whole thing). Thus, we use maps of void pointers
    to their templated data structure pointers, where the memory address
    of the pointer serves as the key.
    Hayk Martirosyan authored
     
    Browse Dir »