aded a field to hodl the total number of semaphores in SemaphoreGroup
changed await_semaphore_group() to return failure if no member semaphore exists
This commit is contained in:
		| @ -52,7 +52,7 @@ class Semaphore(Object) | ||||
| { | ||||
| 	var waiting_head  := nil, | ||||
| 	    waiting_tail  := nil, | ||||
| 	    count         :=   0. | ||||
| 	    count         := 0.    ## semaphore signal count | ||||
|  | ||||
| 	var(#get,#set) heapIndex := -1. | ||||
|  | ||||
| @ -139,7 +139,8 @@ class SemaphoreGroup(Object) | ||||
| 	    last_sem := nil, | ||||
| 	    first_sigsem := nil, | ||||
| 	    last_sigsem := nil, | ||||
| 	    sem_io_count := 0. | ||||
| 	    sem_io_count := 0, | ||||
| 	    sem_count := 0. | ||||
|  | ||||
| (* TODO: good idea to a shortcut way to prohibit a certain method in the heirarchy chain? | ||||
| method(#class,#prohibited) new. | ||||
|  | ||||
| @ -612,7 +612,7 @@ error -> exception | ||||
| 		]. | ||||
|  | ||||
| 		[ | ||||
| 			| s s2 st sg | | ||||
| 			| s s2 st sg ss | | ||||
| 			[ | ||||
| 				s := Socket domain: Socket.Domain.INET type: Socket.Type.STREAM. | ||||
| 				##s connect: (SocketAddress fromString: '127.0.0.1:9999') do: conact. | ||||
| @ -624,6 +624,7 @@ error -> exception | ||||
| ##				###s2 listen: 10; watchInput. | ||||
| ##				s2 listen: 10 do: accact. | ||||
|  | ||||
| (* | ||||
| st := Semaphore new. | ||||
| System addAsyncSemaphore: st. | ||||
| System signal: st afterSecs: 5. | ||||
| @ -632,16 +633,20 @@ sg := SemaphoreGroup new. | ||||
| 'JJJJJJJJJJJ' dump. | ||||
| sg wait. | ||||
| 'YYYYYYYYYYYYYYY' dump. | ||||
| *) | ||||
|  | ||||
| ###[ while (1) { '1111' dump. System sleepForSecs: 1 } ] fork. | ||||
|  | ||||
| (* | ||||
| st := Semaphore new. | ||||
| System addAsyncSemaphore: st. | ||||
| System signal: st afterSecs: 20. | ||||
|  | ||||
| *) | ||||
| 				while (true) | ||||
| 				{ | ||||
| 					if (System handleAsyncEvent isError) { break }. | ||||
| 					ss := System handleAsyncEvent. | ||||
| 					if (ss isError) { break }. | ||||
| 					###if (ss == st) { System removeAsyncSemaphore: st }. | ||||
| 				}. | ||||
| 			] | ||||
| 			ensure: | ||||
|  | ||||
		Reference in New Issue
	
	Block a user