From: lrn@chromium.org Date: Thu, 11 Aug 2011 09:08:44 +0000 (+0000) Subject: Make threaded tests not use static fields for communication. X-Git-Tag: upstream/4.7.83~18730 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=654417d1a9669fc6e48f5506d89a1c6b445678d6;p=platform%2Fupstream%2Fv8.git Make threaded tests not use static fields for communication. TEST=cctest/Threaded4 Review URL: http://codereview.chromium.org/7620007 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8892 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index d7ba7d7..6bf092d 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -331,16 +331,14 @@ static uint16_t* AsciiToTwoByteString(const char* source) { class TestResource: public String::ExternalStringResource { public: - static int dispose_count; - - explicit TestResource(uint16_t* data) - : data_(data), length_(0) { + explicit TestResource(uint16_t* data, int* counter = NULL) + : data_(data), length_(0), counter_(counter) { while (data[length_]) ++length_; } ~TestResource() { i::DeleteArray(data_); - ++dispose_count; + if (counter_ != NULL) ++*counter_; } const uint16_t* data() const { @@ -353,23 +351,18 @@ class TestResource: public String::ExternalStringResource { private: uint16_t* data_; size_t length_; + int* counter_; }; -int TestResource::dispose_count = 0; - - class TestAsciiResource: public String::ExternalAsciiStringResource { public: - static int dispose_count; - - explicit TestAsciiResource(const char* data) - : data_(data), - length_(strlen(data)) { } + explicit TestAsciiResource(const char* data, int* counter = NULL) + : data_(data), length_(strlen(data)), counter_(counter) { } ~TestAsciiResource() { i::DeleteArray(data_); - ++dispose_count; + if (counter_ != NULL) ++*counter_; } const char* data() const { @@ -382,20 +375,18 @@ class TestAsciiResource: public String::ExternalAsciiStringResource { private: const char* data_; size_t length_; + int* counter_; }; -int TestAsciiResource::dispose_count = 0; - - THREADED_TEST(ScriptUsingStringResource) { - TestResource::dispose_count = 0; + int dispose_count = 0; const char* c_source = "1 + 2 * 3"; uint16_t* two_byte_source = AsciiToTwoByteString(c_source); { v8::HandleScope scope; LocalContext env; - TestResource* resource = new TestResource(two_byte_source); + TestResource* resource = new TestResource(two_byte_source, &dispose_count); Local source = String::NewExternal(resource); Local