activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Albert Strasheim (JIRA)" <>
Subject [jira] Created: (AMQCPP-125) Decaf: Random
Date Sun, 10 Jun 2007 14:11:33 GMT
Decaf: Random

                 Key: AMQCPP-125
             Project: ActiveMQ C++ Client
          Issue Type: New Feature
    Affects Versions: 2.2
            Reporter: Albert Strasheim
            Assignee: Nathan Mittler
            Priority: Minor
         Attachments: Randomv1.diff

Attached is a patch that implements a Random class that works the same as java.util.Random.
This code can probably go into Decaf. The patch puts it in activemq/util for now.

I adapted the code from Harmony's implementation of Random:

I couldn't find a test for java.util.Random in the Harmony sources (just took a quick look),
so I used the values from the Mauve test:

The Mauve tests are licensed under the GPL. Does using a few values from this test cause problems
as far as licensing of this new code goes? Hopefully not.

The port to C++ was more or less straightforward. There were three main issues:

1. C++ doesn't have >>>. If I understand >>> correctly, in C++ it's equivalent
to doing >> on an unsigned type.

2. You can't shift more than 31 places at a time in a portable manner. This is because at
least the Intel shift instructions only look at the bottom 5 bits of the register that tells
it how far to shift. As far as I know, the easiest solution is just to shift multiple times.

3. Some java.util.Random methods are synchronized. I haven't included this functionality in
the first version of the patch. It should be easy to add.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message