diff options
author | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 17:08:36 +0000 |
---|---|---|
committer | deanm@google.com <deanm@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-22 17:08:36 +0000 |
commit | d35df912a93adafcea593382ff12d0a6a15a9f48 (patch) | |
tree | 1543e49951e72b08a76cda3c41fe97c17edbbe57 /base/simple_thread_unittest.cc | |
parent | 781ff1569b156fd315cea32707334454af6b3704 (diff) | |
download | chromium_src-d35df912a93adafcea593382ff12d0a6a15a9f48.zip chromium_src-d35df912a93adafcea593382ff12d0a6a15a9f48.tar.gz chromium_src-d35df912a93adafcea593382ff12d0a6a15a9f48.tar.bz2 |
Make CallWrappers multiuse. No longer make CallWrapper->Run() self deleting. Since the SimpleThread API backs to joinable threads, the common use case makes it simple for the caller to manage the CallWrapper memory, and this makes everything much clearer. This also allows a CallWrapper's Run() to be called multiple times. This also moves CallWrapper into the base namespace, which I'm told is all the rage these days.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1224 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/simple_thread_unittest.cc')
-rw-r--r-- | base/simple_thread_unittest.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/base/simple_thread_unittest.cc b/base/simple_thread_unittest.cc index c894637..fcdabda 100644 --- a/base/simple_thread_unittest.cc +++ b/base/simple_thread_unittest.cc @@ -53,10 +53,11 @@ void SignalEvent(base::WaitableEvent* event) { TEST(SimpleThreadTest, CreateAndJoin) { int stack_int = 0; - CallWrapper* wrapper = NewFunctionCallWrapper(SetInt, &stack_int, 7); + scoped_ptr<base::CallWrapper> wrapper( + base::NewFunctionCallWrapper(SetInt, &stack_int, 7)); EXPECT_EQ(0, stack_int); scoped_ptr<base::SimpleThread> thread( - new base::CallWrapperSimpleThread(wrapper)); + new base::CallWrapperSimpleThread(wrapper.get())); EXPECT_FALSE(thread->HasBeenStarted()); EXPECT_FALSE(thread->HasBeenJoined()); EXPECT_EQ(0, stack_int); @@ -75,8 +76,10 @@ TEST(SimpleThreadTest, WaitForEvent) { // Create a thread, and wait for it to signal us. base::WaitableEvent event(true, false); - scoped_ptr<base::SimpleThread> thread(new base::CallWrapperSimpleThread( - NewFunctionCallWrapper(SignalEvent, &event))); + scoped_ptr<base::CallWrapper> wrapper( + base::NewFunctionCallWrapper(SignalEvent, &event)); + scoped_ptr<base::SimpleThread> thread( + new base::CallWrapperSimpleThread(wrapper.get())); EXPECT_FALSE(event.IsSignaled()); thread->Start(); @@ -89,8 +92,10 @@ TEST(SimpleThreadTest, Named) { base::WaitableEvent event(true, false); base::SimpleThread::Options options; + scoped_ptr<base::CallWrapper> wrapper( + base::NewFunctionCallWrapper(SignalEvent, &event)); scoped_ptr<base::SimpleThread> thread(new base::CallWrapperSimpleThread( - NewFunctionCallWrapper(SignalEvent, &event), options, "testy")); + wrapper.get(), options, "testy")); EXPECT_EQ(thread->name_prefix(), "testy"); EXPECT_FALSE(event.IsSignaled()); |