BarryServer : Git

All the code for all my projects
// BarryServer : Git / Nucleus / commit / e8e484f3952a9a3b7df1c3f5763a794a51ea6966 / include / nucleus / object.h

// Related

Nucleus

Barry Object locking e8e484f (3 years, 3 months ago)
diff --git a/include/nucleus/object.h b/include/nucleus/object.h
index bcd7c9a..3103736 100644
--- a/include/nucleus/object.h
+++ b/include/nucleus/object.h
@@ -1,13 +1,30 @@
 #ifndef _NUCLEUS_OBJECT_H
 #define _NUCLEUS_OBJECT_H
 
+#include <sys/types.h>
+#include <nucleus/cpu.h>
+
 typedef struct ObjectType ObjectType;
+struct Object;
 typedef struct Object Object;
+typedef struct Spinlock Spinlock;
+
+typedef struct Task Task; /* Just a pointer, no need for full definition */
+
+/* Spinlock */
+struct Spinlock {
+	char locked;
+	refcount_t usage;
+	union {
+		Task *owner;
+		cpu_t cpu;
+	};
+};
 
 /* Object Type */
 struct ObjectType {
 	unsigned int count;
-	unsigned int usage;
+	refcount_t usage;
 	void *(*new)(void);
 	void (*delete)(Object *);
 };
@@ -15,11 +32,14 @@ struct ObjectType {
 /* Object */
 struct Object {
 	ObjectType *type;
-	unsigned int usage;
+	refcount_t usage;
+	Spinlock lock;
 };
 
 void *get(void *addr);
 void put(void *addr);
 void *new(ObjectType *type);
+void lock(void *addr);
+void unlock(void *addr);
 
 #endif