/vqdr/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/vqdr/trunk

« back to all changes in this revision

Viewing changes to src/utils/random.vala

  • Committer: Gustav Hartvigsson
  • Date: 2022-06-01 19:13:34 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20220601191334-gxeiyrs5j9cvbsam
* Switch rand from static Randow instance, to static GLib.Once<Random>. This should be safer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
  [CCode (cname = "VRandom", cprefix = "v_random_")]
15
15
  public class Random {
16
16
    
17
 
    private static Random? _instance = null;
 
17
    private static GLib.Once<Utils.Random> _instance;
18
18
    
19
19
    private GLib.Rand rand;
20
20
    
23
23
    }
24
24
    
25
25
    public static Random get_instance () {
26
 
      if (_instance == null) {
27
 
       _instance = new Random ();
28
 
      }
29
 
      return _instance;
 
26
      return _instance.once (() => {
 
27
        return new Random ();
 
28
      });
30
29
    }
31
30
    
32
31
    /* **** Instance versions *** */