Commit a9e57371 authored by Mat's avatar Mat
Browse files

Remove the msync/mlock/munlock module functions

These functions were just wrappers to methods of the numpy array base
object which can be accessed directly.
parent f59fb013
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -56,18 +56,6 @@ static PyMethodDef module_functions[] = {
	  "List all existing numpy arrays from shared memory" },
#endif

	{ "msync", (PyCFunction) shared_array_msync,
	  METH_VARARGS | METH_KEYWORDS,
	  "Synchronise a file with a memory map (msync(2) wrapper)" },

	{ "mlock", (PyCFunction) shared_array_mlock,
	  METH_VARARGS | METH_KEYWORDS,
	  "Lock the array in memory (mlock(2) wrapper)" },

	{ "munlock", (PyCFunction) shared_array_munlock,
	  METH_VARARGS | METH_KEYWORDS,
	  "Unlock the array in memory (munlock(2) wrapper)" },

	{ NULL, NULL, 0, NULL }
};

+0 −5
Original line number Diff line number Diff line
@@ -53,11 +53,6 @@ extern PyObject *shared_array_delete(PyObject *self, PyObject *args);
extern PyObject *shared_array_list(PyObject *self, PyObject *args);
#endif

/* Memory locking functions */
extern PyObject *shared_array_msync(PyObject *self, PyObject *args, PyObject *kwds);
extern PyObject *shared_array_mlock(PyObject *self, PyObject *args, PyObject *kwds);
extern PyObject *shared_array_munlock(PyObject *self, PyObject *args, PyObject *kwds);

/* Support functions */
extern int open_file(const char *name, int flags, mode_t mode);
extern int unlink_file(const char *name);

src/shared_array_mlock.c

deleted100644 → 0
+0 −58
Original line number Diff line number Diff line
/* 
 * This file is part of SharedArray.
 * Copyright (C) 2014-2017 Mathieu Mirmont <mat@parad0x.org>
 * 
 * SharedArray is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 * 
 * SharedArray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SharedArray.  If not, see <http://www.gnu.org/licenses/>.
 */

#define NPY_NO_DEPRECATED_API	NPY_1_8_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL	SHARED_ARRAY_ARRAY_API
#define NO_IMPORT_ARRAY

#include <Python.h>
#include <numpy/arrayobject.h>
#include "shared_array.h"
#include "map_owner.h"

/*
 * Method: SharedArray.mlock()
 */
PyObject *shared_array_mlock(PyObject *self, PyObject *args, PyObject *kwds)
{
	static char *kwlist[] = { "array", NULL };
	PyObject *array;
	PyObject *map_owner;

	/* Parse the arguments */
	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist,
					 &PyArray_Type, &array))
		return NULL;

	/* Get the base object */
	if (!(map_owner = PyArray_BASE((PyArrayObject *) array))) {
		PyErr_Format(PyExc_RuntimeError,
			     "Can't find the base object of the given numpy array");
		return NULL;
	}

	/* Make sure that the base object is of a MapOwner */
	if (!PyMapOwner_Check(map_owner)) {
		PyErr_Format(PyExc_RuntimeError,
			     "The base object of the given numpy array isn't a SharedArray");
		return NULL;
	}
	
	/* Call the mlock method */
	return PyObject_CallMethod(map_owner, "mlock", NULL);
}

src/shared_array_msync.c

deleted100644 → 0
+0 −60
Original line number Diff line number Diff line
/* 
 * This file is part of SharedArray.
 * Copyright (C) 2014-2017 Mathieu Mirmont <mat@parad0x.org>
 * 
 * SharedArray is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 * 
 * SharedArray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SharedArray.  If not, see <http://www.gnu.org/licenses/>.
 */

#define NPY_NO_DEPRECATED_API	NPY_1_8_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL	SHARED_ARRAY_ARRAY_API
#define NO_IMPORT_ARRAY

#include <Python.h>
#include <numpy/arrayobject.h>
#include "shared_array.h"
#include "map_owner.h"

/*
 * Method: SharedArray.msync()
 */
PyObject *shared_array_msync(PyObject *self, PyObject *args, PyObject *kwds)
{
	static char *kwlist[] = { "array", "flags", NULL };
	PyObject *array;
	PyObject *map_owner;
	PyObject *flags;

	/* Parse the arguments */
	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", kwlist,
					 &PyArray_Type, &array,
					 &PyLong_Type, &flags))
		return NULL;

	/* Get the base object */
	if (!(map_owner = PyArray_BASE((PyArrayObject *) array))) {
		PyErr_Format(PyExc_RuntimeError,
			     "Can't find the base object of the given numpy array");
		return NULL;
	}

	/* Make sure that the base object is of a MapOwner */
	if (!PyMapOwner_Check(map_owner)) {
		PyErr_Format(PyExc_RuntimeError,
			     "The base object of the given numpy array isn't a SharedArray");
		return NULL;
	}
	
	/* Call the msync method */
	return PyObject_CallMethod(map_owner, "msync", "O", flags);
}

src/shared_array_munlock.c

deleted100644 → 0
+0 −58
Original line number Diff line number Diff line
/* 
 * This file is part of SharedArray.
 * Copyright (C) 2014-2017 Mathieu Mirmont <mat@parad0x.org>
 * 
 * SharedArray is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 * 
 * SharedArray is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with SharedArray.  If not, see <http://www.gnu.org/licenses/>.
 */

#define NPY_NO_DEPRECATED_API	NPY_1_8_API_VERSION
#define PY_ARRAY_UNIQUE_SYMBOL	SHARED_ARRAY_ARRAY_API
#define NO_IMPORT_ARRAY

#include <Python.h>
#include <numpy/arrayobject.h>
#include "shared_array.h"
#include "map_owner.h"

/*
 * Method: SharedArray.munlock()
 */
PyObject *shared_array_munlock(PyObject *self, PyObject *args, PyObject *kwds)
{
	static char *kwlist[] = { "array", NULL };
	PyObject *array;
	PyObject *map_owner;

	/* Parse the arguments */
	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist,
					 &PyArray_Type, &array))
		return NULL;

	/* Get the base object */
	if (!(map_owner = PyArray_BASE((PyArrayObject *) array))) {
		PyErr_Format(PyExc_RuntimeError,
			     "Can't find the base object of the given numpy array");
		return NULL;
	}

	/* Make sure that the base object is of a MapOwner */
	if (!PyMapOwner_Check(map_owner)) {
		PyErr_Format(PyExc_RuntimeError,
			     "The base object of the given numpy array isn't a SharedArray");
		return NULL;
	}
	
	/* Call the munlock method */
	return PyObject_CallMethod(map_owner, "munlock", NULL);
}