rgctest.C 857 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //#define __debug_obj123
  2. #include <iostream>
  3. #include <functional>
  4. using namespace std;
  5. #include "rgc.H"
  6. using namespace RGC;
  7. struct c1: public Object
  8. {
  9. Ref<Object> a;
  10. //Object* a;
  11. };
  12. void func1()
  13. {
  14. cout << "func1 called" << endl;
  15. }
  16. void call10times(function<void()> func)
  17. {
  18. for(int i=0;i<10000000;i++)
  19. func();
  20. }
  21. void aaaaa()
  22. {
  23. Ref<Object> tmp=newObj<Object>();
  24. cout << tmp->refCount << endl;
  25. c1 obj;
  26. obj.a=tmp;
  27. cout << tmp->refCount << endl;
  28. obj.a=newObj<Object>();
  29. cout << tmp->refCount << endl;
  30. Ref<Object> r(obj.a);
  31. Ref<Object> r1(obj);
  32. obj.a=NULL;
  33. //tmp=new Object();
  34. }
  35. int rgctest_main(int argc, char **argv)
  36. {
  37. //aaaaa();
  38. /*Ref<FileStream> fs("/dev/urandom",O_RDONLY);
  39. Ref<StreamReader> sr(*fs);
  40. Ref<StringBuilder> sb;
  41. cout << fs() << endl;
  42. sr->ReadLine(*sb);
  43. cout << sb->ToCString() << endl;*/
  44. aaaaa();
  45. }