rev 669 - in trunk: include/prothon src

SVN User <[email protected]> Sun, 27 Jun 2004 17:07:57 -0400
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-06-27 17:07:54 -0400 (Sun, 27 Jun 2004)
New Revision: 669

Modified:
   trunk/include/prothon/prothon.h
   trunk/src/lock.c
   trunk/src/memory_mgr.c
   trunk/src/object.c
   trunk/src/object.h
Log:
started object modification notification system

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h	2004-06-27 08:48:35 UTC (rev 668)
+++ trunk/include/prothon/prothon.h	2004-06-27 21:07:54 UTC (rev 669)
@@ -217,18 +217,22 @@
 
 typedef struct obj_s {
 	obj_state_t		state			:3; // u8_t :2 when not debugging
+	u8_t			scanned			:1;	
 	data_type_t		data_type		:3; // u8_t :2 when not debugging
 	u8_t			imm_data_len	:4;
 	access_t		rd_access		:2;	
 	access_t		wr_access		:2;	
+	u8_t			archived		:1;	
+	u8_t			rd_notify		:1;	
+	u8_t			wr_notify		:1;	
+	u8_t			del_notify		:1;	
+	u8_t 			has_attrs		:1;
 	u8_t			unclonable		:1;
-	u8_t			archived		:1;	
 	u8_t			immutable		:1;
-	u8_t			scanned			:1;	
-	u8_t 			has_attrs		:1;
+	u8_t			lock_kywrd		:1;
 	u8_t			del_locked		:1;
-	u8_t			rdlock_cnt		:6; // :7 when not debugging
-	u8_t			wrlock_req_cnt	:6; // :7 when not debugging
+	u8_t			rdlock_cnt		:6;
+	u8_t			wrlock_req_cnt	:6;
 	i32_t			wrlock;
 	attr_proto_t	attr_proto;
 	obj_data_t		data;

Modified: trunk/src/lock.c
===================================================================
--- trunk/src/lock.c	2004-06-27 08:48:35 UTC (rev 668)
+++ trunk/src/lock.c	2004-06-27 21:07:54 UTC (rev 669)
@@ -71,6 +71,45 @@
 
 int obj_wrlock_waiting;
 
+DECLARE_PR_LOCK(notify_lock);
+obj_p notify_dict;
+
+//********************************* init_notify *******************************
+void init_notify(isp ist) {
+	pr_lock(&notify_lock);
+	notify_dict = new_dict_obj(ist, 10);
+	pr_unlock(&notify_lock);
+}
+
+//********************************* read_notify *******************************
+void read_notify(isp ist, obj_p obj){
+	pr_lock(&notify_lock);
+
+
+	pr_unlock(&notify_lock);
+}
+
+//********************************* write_notify ******************************
+void write_notify(isp ist, obj_p obj){
+	pr_lock(&notify_lock);
+
+
+	pr_unlock(&notify_lock);
+}
+
+//********************************* delete_notify *****************************
+void delete_notify(isp ist, obj_p obj){
+	int del_notify;
+	get_wrlock(obj, FALSE);
+	del_notify = obj->del_notify;
+	free_wrlock(obj);
+	if (!del_notify) return;
+	pr_lock(&notify_lock);
+	
+
+	pr_unlock(&notify_lock);
+}
+
 //********************************* get_wrlock ********************************
 void get_wrlock(obj_p obj, int force_wait) {
 	if (!force_wait && lock((obj)->wrlock)) return;
@@ -105,6 +144,7 @@
 	clist_push(lockstack, obj);
 	obj->rdlock_cnt++;
 	obj->state = OBJ_STATE_NEW_OR_MARKED;
+	if (obj->rd_notify) read_notify(ist, obj);
 	free_wrlock(obj);
 	return TRUE;
 }
@@ -112,8 +152,6 @@
 //********************************* read_lock *********************************
 int read_lock(isp ist, obj_p obj) {
 	get_wrlock(obj, NO_WAIT);
-	if ((intptr_t)obj == 0x009ab9e0)
-		obj = obj + 0;
 	if (ist->access < obj->rd_access) {
 		raise_exception(ist, OBJ(PERMISSION_EXC), "read permission exception");
 		free_wrlock(obj);
@@ -132,6 +170,7 @@
 	clist_push(lockstack, obj);
 	obj->rdlock_cnt++;
 	obj->state = OBJ_STATE_NEW_OR_MARKED;
+	if (obj->rd_notify) read_notify(ist, obj);
 	free_wrlock(obj);
 	return FALSE;
 }
@@ -172,6 +211,7 @@
 		free_wrlock(obj);
 		return FALSE;
 	}
+	if (obj->wr_notify) write_notify(ist, obj);
 	return TRUE;
 }
 
@@ -207,6 +247,7 @@
 		apr_thread_mutex_unlock(write_mutex);
 		obj->rdlock_cnt += sav_cnt;
 	}
+	if (obj->wr_notify) write_notify(ist, obj);
 	return FALSE;
 }
 

Modified: trunk/src/memory_mgr.c
===================================================================
--- trunk/src/memory_mgr.c	2004-06-27 08:48:35 UTC (rev 668)
+++ trunk/src/memory_mgr.c	2004-06-27 21:07:54 UTC (rev 669)
@@ -275,6 +275,7 @@
 		while(obj) {
 			obj_count++;
 			if (obj->state != OBJ_STATE_NEW_OR_MARKED && !obj->del_locked) {
+				delete_notify(ist, obj);
 				call_func(ist, obj, SYM(DEL_), 0, NULL, NULL);
 				check_exceptions(ist);
 				mm_write_lock(ist, obj);

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c	2004-06-27 08:48:35 UTC (rev 668)
+++ trunk/src/object.c	2004-06-27 21:07:54 UTC (rev 669)
@@ -248,6 +248,7 @@
 	OBJ(SYMBOLS)            = NEW_DICT(SYM_ENUM_COUNT+100);
 
 	init_symbol(ist);
+	init_notify(ist);
 
 	set_obj_doc(OBJ(SYMBOLS), "Symbols: dictionary of all symbol objects");
 

Modified: trunk/src/object.h
===================================================================
--- trunk/src/object.h	2004-06-27 08:48:35 UTC (rev 668)
+++ trunk/src/object.h	2004-06-27 21:07:54 UTC (rev 669)
@@ -184,5 +184,8 @@
 #define SEQ_TYPE_TUPLE          2
 #define SEQ_TYPE_LIST           3
 
+extern obj_p notify_dict;
+void init_notify(isp ist);
+void delete_notify(isp ist, obj_p obj);
 
 #endif  // #define OBJECT_H