Posts

Showing posts from August 11, 2018

Lock-free Immutable ConcurrentQueue

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0; up vote 3 down vote favorite 1 Similar to the code review I posted last week for an agent-based immutable replacement for ConcurrentDictionary , I have also created an agent-based immutable replacement for ConcurrentQueue . This uses a MailboxProcessor and an immutable queue based on Okasaki's implementation in Purely Functional Data Structures with a few extra operations. I am particularly interested in understanding if there's any way I can combine the QueueAgent and the InternalQueueAgent into one type (without the mutual-recursion), and if there's any way to do the asynchronous Peek and Dequeue operations without the internal ImmutableQueue s for the PeekListeners and DequeueListeners . The idea behind those operations is to support a "yield until a message is available" behavior similar to an asynchronous Peek or Rece...

Ruby Regex to update various variables inside a file

Image
Clash Royale CLAN TAG #URR8PPP .everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0; up vote 3 down vote favorite In our applications we have a version file that has three variables that are then joined to create a string that can be used for the semantic version. The file looks like: # frozen_string_literal: true major = 0 minor = 1 patch = 0 PORTAL_VERSION = [major, minor, patch].join('.') And then we update it using the following from our CI server: @version = '0.1.1' # this is passed from somewhere puts 'updating version' version_file = File.open("version.rb").read version = @version.split('.') version_file = version_file.gsub(/(major = w)/, "major = #version[0]") version_file = version_file.gsub(/(minor = w)/, "minor = #version[1]") version_file = version_file.gsub(/(patch = w)/, "patch = #version[2]") File.open('version.rb', 'wb') file puts ...