User loginNavigation |
archivesThread-safe Singleton in C#This has two parts. Please read first part first and think and then read second part. 1 public class SingletonClass 2 { 3 private SingletonClass () { Constructor (); } 4 static SingletonClass instance; 5 public static SingletonClass Instance 6 { 7 get 8 { 9 lock (typeof (SingletonClass)) 10 { 11 if (instance == null) 12 instance = new SingletonClass (); 13 lock (instance) 14 { 15 return instance; 16 } 17 } 18 } 19 } 20 void Constructor () { } 21 } -------------------------------------------------------------------------------- + Second part: 1 public class SingletonClass 2 { 3 public static object Hey_IAmStillUsingThisInstance_Lock = new object (); 4 private SingletonClass () { Constructor (); } 5 static SingletonClass instance; 6 public static SingletonClass Instance 7 { 8 get 9 { 10 lock (typeof (SingletonClass)) 11 { 12 if (instance == null) 13 instance = new SingletonClass (); 14 lock (instance) 15 { 16 return instance; 17 } 18 } 19 } 20 } 21 void Constructor () { } 22 public void DoSomthing () { } 23 } 100 static void Main(string[] args) 101 { 102 lock (SingletonClass.Hey_IAmStillUsingThisInstance_Lock) 103 { 104 SingletonClass.Instance.DoSomthing (); 105 } 106 } This filth is shared memory. >:( Declarative AssemblerDeclarative Assembler. Christopher Kumar Anand, Jacques Carette, Wolfram Kahl, Cale Gibbard, Ryan Lortie. SQRL Technical Report #20, 2004.
I think this paper is a nice followup to the recent discussion of SPE because it goes further than that paper by analyzing what data are necessary to achieve the ultimate goal of optimal or near-optimal instruction scheduling on superscalar architectures. In other words, it strongly suggests that we can do better than simply embedding low-level instructions in a high-level language by instead embedding a graph of desired results (vertices) and instructions for reaching them (edges) which can be analyzed to exploit cache-coherency, pipelining tricks, instruction-level parallelism, etc, or which could be supplied to an external scheduling algorithm based on some entirely different paradigm. Status Report: HOT Pickles, and how to serve themStatus Report: HOT Pickles, and how to serve them, Andreas Rossberg, Guido Tack, and Leif Kornstedt. ML Workshop 2007.
Newspeak, an experimental language in the style of Smalltalk
|
Browse archivesActive forum topics |
Recent comments
22 weeks 1 day ago
22 weeks 1 day ago
22 weeks 1 day ago
44 weeks 2 days ago
48 weeks 4 days ago
50 weeks 1 day ago
50 weeks 1 day ago
1 year 5 days ago
1 year 5 weeks ago
1 year 5 weeks ago