From 966061fcb0e2ec4d5d7ed9c6c280eefb27209da7 Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Fri, 6 Jun 2008 11:39:41 +0200 Subject: Removed Ice-E --- cppe/demo/IceE/workqueue/WorkQueue.cpp | 105 --------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 cppe/demo/IceE/workqueue/WorkQueue.cpp (limited to 'cppe/demo/IceE/workqueue/WorkQueue.cpp') diff --git a/cppe/demo/IceE/workqueue/WorkQueue.cpp b/cppe/demo/IceE/workqueue/WorkQueue.cpp deleted file mode 100644 index d12d0ef2ca6..00000000000 --- a/cppe/demo/IceE/workqueue/WorkQueue.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// ********************************************************************** -// -// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. -// -// This copy of Ice-E is licensed to you under the terms described in the -// ICEE_LICENSE file included in this distribution. -// -// ********************************************************************** - -#include - -#include -#include - -using namespace std; - -class WorkQueue : public IceUtil::Thread -{ -public: - - WorkQueue() { } - ~WorkQueue() { } - - virtual void - run() - { - while(1) - { - string item = nextItem(); - if(item == "destroy") - { - break; - } - - printf("work item: %s\n", item.c_str()); - IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1)); - } - } - - void - add(const string& item) - { - IceUtil::Monitor::Lock lock(_monitor); - if(_queue.empty()) - { - _monitor.notify(); - } - _queue.push_back(item); - } - -private: - - string - nextItem() - { - IceUtil::Monitor::Lock lock(_monitor); - while(_queue.empty()) - { - _monitor.wait(); - } - - string item = _queue.front(); - _queue.pop_front(); - return item; - } - - - IceUtil::Monitor _monitor; - list _queue; -}; - -typedef IceUtil::Handle WorkQueuePtr; - -int -main() -{ - try - { - WorkQueuePtr h = new WorkQueue(); - IceUtil::ThreadControl control = h->start(); - printf("Pushing work items"); - printf("."); fflush(stdout); - h->add("item1"); - printf("."); fflush(stdout); - h->add("item2"); - printf("."); fflush(stdout); - h->add("item3"); - printf("."); fflush(stdout); - h->add("item4"); - printf("."); fflush(stdout); - h->add("item5"); - printf("."); fflush(stdout); - h->add("destroy"); - printf(" ok\n"); - printf("Waiting for WorkQueue to terminate\n"); - control.join(); - } - catch(const IceUtil::Exception& ex) - { - fprintf(stderr, "%s\n", ex.toString().c_str()); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} -- cgit v1.2.3