changing the GC algorith. Only operations left to an deleted insertion can be garbage collected. (incomplete!)

This commit is contained in:
DadaMonad 2015-01-08 12:10:57 +00:00
parent af3cd2361a
commit a1b07f84ea
14 changed files with 244 additions and 33065 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
<head>
<meta charset=utf-8 />
<title>PeerJs Json Example</title>
<script src="../../../Connector/xmpp-connector/xmpp-connector.js"></script>
<script src="../../../Yatta-Connectors/xmpp-connector/xmpp-connector.js"></script>
<script src="../../build/browser/yatta.js"></script>
<script src="./index.js"></script>
</head>

View File

@ -1,11 +1,11 @@
<link rel="import" href="../../yatta-element.html">
<link rel="import" href="../../../Connector/strophe-connector/strophe-connector.html">
<link rel="import" href="../../../Yatta-Connectors/xmpp-connector/xmpp-connector.html">
<link rel="import" href="../../bower_components/paper-slider/paper-slider.html">
<polymer-element name="yatta-test" attributes="yatta connector stuff">
<template>
<strophe-connector id="connector" connector={{connector}}></strophe-connector>
<xmpp-connector id="connector" connector={{connector}}></xmpp-connector>
<yatta-element connector={{connector}} val={{yatta}}>
<yatta-property name="slider" val={{slider}}>
</yatta-property>

View File

@ -77,15 +77,7 @@ gulp.task 'mocha', ->
gulp.src files.test, { read: false }
.pipe plumber()
.pipe mocha {reporter : 'list'}
.pipe ignore.include '**/*.coffee'
.pipe browserify
transform: ['coffeeify']
extensions: ['.coffee']
debug: true
.pipe rename
extname: ".js"
.pipe gulp.dest 'build/test/'
.pipe gulpif '!**/', git.add({args : "-A"})
gulp.task 'lint', ->
gulp.src files.all

View File

@ -10,6 +10,9 @@ adaptConnector = (connector, engine, HB, execution_listener)->
if o.uid.creator is HB.getUserId() and (typeof o.uid.op_number isnt "string")
connector.broadcast o
if connector.invokeSync?
HB.setInvokeSyncHandler connector.invokeSync
execution_listener.push send_
# For the XMPPConnector: lets send it as an array
# therefore, we have to restructure it later
@ -43,6 +46,5 @@ adaptConnector = (connector, engine, HB, execution_listener)->
if op.uid.creator isnt HB.getUserId()
engine.applyOp op
HB.setInvokeSyncHandler connector.invokeSync
module.exports = adaptConnector

View File

@ -273,18 +273,18 @@ module.exports = (HB)->
if o?
@deleted_by.push o
garbagecollect = false
if not (@prev_cl? and @next_cl?) or @prev_cl.isDeleted()
if @next_cl.isDeleted()
garbagecollect = true
super garbagecollect
if callLater
@callOperationSpecificDeleteEvents(o)
if @next_cl?.isDeleted()
# garbage collect next_cl
@next_cl.applyDelete()
if @prev_cl?.isDeleted()
# garbage collect prev_cl
@prev_cl.applyDelete()
cleanup: ()->
# TODO: Debugging
if @prev_cl?.isDeleted()
if @next_cl?.isDeleted()
# delete all ops that delete this insertion
for d in @deleted_by
d.cleanup()
@ -300,7 +300,8 @@ module.exports = (HB)->
@prev_cl.next_cl = @next_cl
@next_cl.prev_cl = @prev_cl
super
else if @next_cl? and @prev_cl?
throw new Error "This insertion was not supposed to be deleted!"
#
# @private

View File

@ -343,12 +343,13 @@ module.exports = (HB)->
# @param {ReplaceManager} parent Used to replace this Replaceable with another one.
# @param {Object} uid A unique identifier. If uid is undefined, a new uid will be created.
#
constructor: (content, parent, uid, prev, next, origin)->
constructor: (content, parent, uid, prev, next, origin, is_deleted)->
@saveOperation 'content', content
@saveOperation 'parent', parent
if not (prev? and next?)
throw new Error "You must define prev, and next for Replaceable-types!"
super uid, prev, next, origin
@is_deleted = is_deleted
type: "Replaceable"
@ -379,12 +380,13 @@ module.exports = (HB)->
callOperationSpecificInsertEvents: ()->
if @next_cl.type is "Delimiter" and @prev_cl.type isnt "Delimiter"
# this replaces another Replaceable
old_value = @prev_cl.content
@parent.callEventDecorator [
type: "update"
changedBy: @uid.creator
oldValue: old_value
]
if not @is_deleted # When this is received from the HB, this could already be deleted!
old_value = @prev_cl.content
@parent.callEventDecorator [
type: "update"
changedBy: @uid.creator
oldValue: old_value
]
@prev_cl.applyDelete()
else if @next_cl.type isnt "Delimiter"
# This won't be recognized by the user, because another
@ -417,6 +419,7 @@ module.exports = (HB)->
'prev': @prev_cl.getUid()
'next': @next_cl.getUid()
'uid' : @getUid()
'is_deleted': @is_deleted
}
if @origin? and @origin isnt @prev_cl
json["origin"] = @origin.getUid()
@ -430,8 +433,9 @@ module.exports = (HB)->
'prev': prev
'next': next
'origin' : origin
'is_deleted': is_deleted
} = json
new Replaceable content, parent, uid, prev, next, origin
new Replaceable content, parent, uid, prev, next, origin, is_deleted
types['ListManager'] = ListManager
types['MapManager'] = MapManager

View File

@ -124,10 +124,6 @@ module.exports = (HB)->
type: "WordType"
applyDelete: ()->
for textfield in @textfields
textfield.onkeypress = null
textfield.onpaste = null
textfield.oncut = null
o = @beginning
while o?
o.applyDelete()
@ -141,9 +137,10 @@ module.exports = (HB)->
@insertAfter @end.prev_cl, content
insertAfter: (left, content)->
while left.isDeleted()
left = left.prev_cl # find the first character to the left, that is not deleted. Case position is 0, its the Delimiter.
right = left.next_cl
while right.isDeleted()
right = right.next_cl # find the first character to the right, that is not deleted. In the case that position is 0, its the Delimiter.
left = right.prev_cl
if content.type?
(new TextInsert content, undefined, left, right).execute()
else
@ -243,6 +240,10 @@ module.exports = (HB)->
# consume all text-insert changes.
textfield.onkeypress = (event)->
if word.is_deleted
# if word is deleted, do not do anything ever again
textfield.onkeypress = null
return true
char = null
if event.key?
if event.charCode is 32
@ -265,8 +266,16 @@ module.exports = (HB)->
event.preventDefault()
textfield.onpaste = (event)->
if word.is_deleted
# if word is deleted, do not do anything ever again
textfield.onpaste = null
return true
event.preventDefault()
textfield.oncut = (event)->
if word.is_deleted
# if word is deleted, do not do anything ever again
textfield.oncut = null
return true
event.preventDefault()
#
@ -277,6 +286,10 @@ module.exports = (HB)->
# Every browser supports keyCode. Let's stick with it for now..
#
textfield.onkeydown = (event)->
if word.is_deleted
# if word is deleted, do not do anything ever again
textfield.onkeydown = null
return true
pos = Math.min textfield.selectionStart, textfield.selectionEnd
diff = Math.abs(textfield.selectionEnd - textfield.selectionStart)
if event.keyCode? and event.keyCode is 8 # Backspace

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long