| 1 | /*************************************************************************** |
|---|
| 2 | * ioChannel.cc |
|---|
| 3 | * |
|---|
| 4 | * Tue Oct 11 2005 |
|---|
| 5 | * Copyright 2005 Dmytro Milinevskyy |
|---|
| 6 | * milinevskyy@gmail.com |
|---|
| 7 | ****************************************************************************/ |
|---|
| 8 | |
|---|
| 9 | /* |
|---|
| 10 | * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | * it under the terms of the GNU Lesser General Public License version 2.1 as published by |
|---|
| 12 | * the Free Software Foundation; |
|---|
| 13 | * |
|---|
| 14 | * This program is distributed in the hope that it will be useful, |
|---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 17 | * GNU Library General Public License for more details. |
|---|
| 18 | * |
|---|
| 19 | * You should have received a copy of the GNU Lesser General Public License |
|---|
| 20 | * along with this program; if not, write to the Free Software |
|---|
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 22 | */ |
|---|
| 23 | |
|---|
| 24 | /** |
|---|
| 25 | * vim indentation settings |
|---|
| 26 | * set tabstop=4 |
|---|
| 27 | * set shiftwidth=4 |
|---|
| 28 | */ |
|---|
| 29 | |
|---|
| 30 | #include <libdodo/directives.h> |
|---|
| 31 | |
|---|
| 32 | #include <libdodo/ioChannel.h> |
|---|
| 33 | #include <libdodo/xexec.h> |
|---|
| 34 | #include <libdodo/types.h> |
|---|
| 35 | #include <libdodo/pcSyncProcess.h> |
|---|
| 36 | #include <libdodo/pcSyncThread.h> |
|---|
| 37 | #include <libdodo/pcSyncStack.h> |
|---|
| 38 | |
|---|
| 39 | using namespace dodo::io; |
|---|
| 40 | |
|---|
| 41 | #ifndef IO_WO_XEXEC |
|---|
| 42 | channel::__collected_data__::__collected_data__(xexec *a_executor, |
|---|
| 43 | short execObject) : xexec::__collected_data__(a_executor, execObject) |
|---|
| 44 | { |
|---|
| 45 | } |
|---|
| 46 | #endif |
|---|
| 47 | |
|---|
| 48 | //------------------------------------------------------------------- |
|---|
| 49 | |
|---|
| 50 | channel::channel(short protection) : bs(IO_BLOCKSIZE), |
|---|
| 51 | keeper(NULL), |
|---|
| 52 | protection(protection) |
|---|
| 53 | #ifndef IO_WO_XEXEC |
|---|
| 54 | , |
|---|
| 55 | collectedData(this, xexec::OBJECT_XEXEC) |
|---|
| 56 | #endif |
|---|
| 57 | { |
|---|
| 58 | if (protection == channel::PROTECTION_THREAD) |
|---|
| 59 | keeper = new pc::sync::thread; |
|---|
| 60 | else if (protection == channel::PROTECTION_PROCESS) |
|---|
| 61 | keeper = new pc::sync::process(0); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | //------------------------------------------------------------------- |
|---|
| 65 | |
|---|
| 66 | channel::~channel() |
|---|
| 67 | { |
|---|
| 68 | delete keeper; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | //------------------------------------------------------------------- |
|---|