 p = -> #require('util').debug
 i = -> #require('util').inspect
 
+queue = require './syncqueue'
 types = require '../types'
 db = require './db'
 Events = require('./events')

	# model.applyOp 'doc', OPC
	@applyOp = (docName, opData, callback) ->
		p "applyOp #{docName} op #{i opData}"
		# Its important that all ops are applied in order.
		pendingOps[docName] ||= {busy:false, queue:[]}
		pendingOps[docName].queue.push [opData, callback]
		flushOps docName
	
	# Perminantly deletes the specified document.
	# If listeners are attached, they are removed.

				# The op is up to date already. Apply and submit.
				submit()

	queues = {} # docName -> syncQueue

	# Apply an op to the specified document.
	# The callback is passed (error, applied version #)
